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 using jQuery.var div = $("");
$("#box").append(div);$("#box").append("");
var $div = $("", {id: "foo", "class": "a"});
$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.
No comments:
Post a Comment