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...
-
In K-PAX , there are two possible explanations: Prot is crazy. He is truly an alien. There are facts that indicate 1, but also 2. Examples: ...
-
Why this works? I mean, accessing the private variable. class Test { private $q = 0; public function __construct() { $this-...
-
I found this excellent tutorial on regular expressions and while I intuitively understand what "greedy", "reluctant" an...
No comments:
Post a Comment