In this topic, we will learn a jquery Eq selector. jquery Eq selector allows us to select all elements at a specified index.
Jquery Eq Selector:-
jquery Eq selector matches a specific element by counting from the first element to the index value. Suppose that you want to choose the third <p> element on the page. Because the count starts with 0, to select the third <p> element, do the following.
$(‘p:eq(2)’).text(‘Changed this text.’);
jquery Eq selector example:-
In the following HTML example,
we will see how to change the font style of <p> elements which is
equal to the index value. To accomplish this task we can make use of : eq(index)
output:
Paragraph 1-index[0]
Paragraph 2-index[1]
Paragraph 3-index[2]
Paragraph 4-index[3]
Paragraph 5-index[4]
Paragraph 6-index[5]
Paragraph 2-index[1]
Paragraph 3-index[2]
Paragraph 4-index[3]
Paragraph 5-index[4]
Paragraph 6-index[5]
Post A Comment:
0 comments: