I've got 2 ways I can create a Either: Or: What are the drawbacks of using second way other than re-usability? Answer The first option gives you more flexibilty: And of course Another good practice is prefixing your jQuery variables with Placing quotes around the jQuery
.var div = $("");
$("#box").append(div);$("#box").append("");
var $div = $("
$div.click(function(){ /* ... */ });
$("#box").append($div);.html('*')
overrides the content while .append('*')
doesn't, but I guess, this wasn't your question.$
:
Is there any specific reason behind using $ with variable in jQuery"class"
property name will make it more compatible with less flexible browsers.
Friday, 1 July 2016
javascript - The preferred way of creating a new element with jQuery
using
", {id: "foo", "class": "a"});
Subscribe to:
Post Comments (Atom)
c++ - Does curly brackets matter for empty constructor?
Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...
-
A fair amount of the second act of The Dark Knight Rises has a class warfare plotline. This is foreshadowed in the trailers with Selina Ky...
-
I want to create an options array from a string. How can i create an array as { width : 100, height : 200 } from a string ...
-
I'm still trying to wrap my head around how the following expression results in undefined behavior: a = a++; Upon searching SO...
No comments:
Post a Comment