Showing posts with label Performauery TIpsnce. Show all posts
Showing posts with label Performauery TIpsnce. Show all posts

Sunday, January 23, 2011

Jquery Best Practices and Tips.


1.  How To Check If An Element contains a certain class or element with has():

//jQuery 1.4.* includes support for the has method.

$("input").has(".mail").addClass("mail_icon");


2. How To Detect Any Browser:

Detect Safari (if( $.browser.safari)),
Detect IE6 and over (if ($.browser.msie && $.browser.version > 6 )),
Detect IE6 and below (if ($.browser.msie && $.browser.version <= 6 )),
Detect FireFox 2 and above (if ($.browser.mozilla && $.browser.version >= '1.8' ))

3. Always start the selection  From an #id

The fastest selector in jQuery is the ID selector ($('#someid')).
This is because it maps directly to a native JavaScript method, getElementById().

Read More

subversion video