Www ( Tag # Lightsoffnow y Lightsoffnow i Detection t Detection lasearchssearcha Www c Www b Detection e Detection r11w searcha Face e Tag
Lightsoffnow s Detection a Detection c Lightsoffnow r Face Lisearchh Lightsoffnow sosearchfnaw
h
' Lightsoffnow l1csearch' Face Face u Tag csearchisearchnsearch)search})search
Instead, we should listen for the click event at the parent level:
$('#myList).bind('click', function(e){}
}); The parent node acts as a dispatcher and can then do work based on what target element triggered the event. If you find yourself binding on
Although jQuery fails nicely if it does not find any matching elements, it still takes time to look for them. If you have on
<script type="text/javascript>
mylib.article.init();
</script>
</body>
If your page template includes any variety of modules that may or may not be on the page, or for visual reasons you need them to initialize sooner, you could place the initialization function immediately after the module.
<ul id="traffic_light">
<li><input type="radio" class="on" name="light" value="red" /> Red</li>
<li><input type="radio" class="off" name="light" value="yellow" /> Yellow</li>
<li><input type="radio" class="off" name="light" value="green" /> Green</li>
</ul>
<script type="text/javascript>
mylib.traffic_light.init();
</script>
Your Global JS library would look something like this:
var mylib =
{}
},
traffic_light :
{}
}
}
There is a temptation among jQuery developers to hook everything into the
$(window).load(function(){}); Superfluous functionality such as drag and drop, binding visual effects and animations, pre-fetching hidden images, etc., are all good candidates for this technique.
Okay, this isn’t jQuery related, but I had to include it. There is a tendency to make JavaS
Print out this jQuery 1.3 cheat sheet, and make it a goal to eventually understand what each function does. If you find yourself repeating yourself repeating, there is probably an easier (and more efficient) way.