Toggle menu
862
3.8K
30.2K
279.1K
Catglobe Wiki
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

JQuery - Tips: Difference between revisions

From Catglobe Wiki
No edit summary
No edit summary
Line 10: Line 10:
Set an event handler for any element that matches a selector, even if it gets added to the DOM after the initial page load:
Set an event handler for any element that matches a selector, even if it gets added to the DOM after the initial page load:
$('button.someClass').live('click', someFunction);
$('button.someClass').live('click', someFunction);
<br>
4. To hide element
$("a").hide();
<br>
<br>

Revision as of 10:30, 22 April 2010

1. Optimize performance of complex selectors var subset = $(""); $("input[value^=]", subset);
2. Set Context and improve the performance On the core jQuery function, specify the context parameter when. Specifying the context parameter allows jQuery to start from a deeper branch in the DOM, rather than from the DOM root. Given a large enough DOM, specifying the context parameter should translate to performance gains. $("input:radio", document.forms[0]);
3. Live Event Handlers Set an event handler for any element that matches a selector, even if it gets added to the DOM after the initial page load: $('button.someClass').live('click', someFunction);
4. To hide element $("a").hide();