Web design: jQuery selectors: eq(n)


jQuery, famously, offers selectors that a programmer can use to access virtually any element on the page. This post gives an example of the eq(n) selector.

When you click the demo button below, the third H will change. The code:

$(“thisclass:eq(2)”).css(“attribute”,”new_value”)

:eq(2) means the third element, since with computer science, the count starts at 0.

H H H H

I’ll be giving more examples of jQuery selectors in future posts:)

Source:

Pollock, John. jQuery: A Beginner’s Guide. Toronto: McGraw-Hill, 2014.

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Tagged with: , ,

Leave a Reply