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

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

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -