Search, View and Navigation

JavaScript

Stylize the last element in prototype

Attention, open in a new window. PDFPrintE-mail

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

Add your comment

Your name:
Your email:
Your website:
Subject:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification:

Additional Information

What is your job title?












Results