05.01.2013 Views

hide - Understanding jQuery

hide - Understanding jQuery

hide - Understanding jQuery

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The following example will demonstrate the common DOM names in reference to various<br />

HTML elements.<br />

<br />

JavaScript DOM Object Class Name Example<br />

<br />

<br />

$(document).ready(function() // Initializate once the entire DOM finished downloading.<br />

{<br />

var List = ““; // Store list of DOM object names<br />

var ElementNames = [“a”, “b”, “c”, “d”, “e”, “f ”, “g”, “h”, “i”]; // Known id names<br />

// Go through each element name and grab the DIV associated with that id<br />

for (var i = 0; i < ElementNames.length; i++)<br />

{<br />

var Name = document.getElementById(ElementNames[i]); // get DOM object<br />

if (i < ElementNames.length - 1)<br />

List += Name + “\r\n“; // Add line breaks to each line except the last<br />

}<br />

alert(List); // Display the list of names for each DOM element<br />

}); // end of $(document).ready<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Find out what the output of this function is on the following page.<br />

125

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!