JavaScript
Stylize the last element in prototype
Last Updated (Friday, 16 January 2009 02:29) Written by Alex Grande Thursday, 28 August 2008 05:26
JavaScript - JavaScript Design Patterns
Here is an example of removing the last border in a list of elements.
document.observe(”dom:loaded”, function() {
$$(”li:last-child”).invoke(”addClassName”, “last”);
});
Thanks to Dan Dean, web application manager at Pop Multimedia Inc for recommending this code snippet. By adding the class "last" or "lastChild" or whatever you like you can hold all the styles in your css stylesheet. Furthermore the dom:loaded helps the code be executed sooner in the page load.
You can compare to jQuery by going here
| < Prev | Next > |
|---|


