javascript - jQuery Tips and Tricks -


syntax

data storage

optimization

miscellaneous

creating html element , keeping reference

var newdiv = $("<div />");  newdiv.attr("id", "mynewdiv").appendto("body");  /* whenever want append new div created,     can reference "newdiv" variable */ 


checking if element exists

if ($("#somediv").length) {     // exists... } 


writing own selectors

$.extend($.expr[":"], {     over100pixels: function (e)     {         return $(e).height() > 100;     } });  $(".box:over100pixels").click(function () {     alert("the element clicked on 100 pixels height"); }); 

Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -