⊗jqSePr 90 of 113 menu

Previous set in jQuery

Sometimes when building jQuery chains you need to go back to the previous set. This is done using the end method.

The following example shows the HTML code:

<p class="www">text</p> <p class="www">text</p> <p>text</p> <p>text</p>

Our task is to first find all paragraphs, then select paragraphs with class www from those found using filter method and, using append method, append text '!' to their end. Then we go back to the previous set (which is the set $('p')) using end and append text '?' to their end.

It turns out that paragraphs with class www will have text '!?', and regular paragraphs will have text '?':

$('p').filter('.www').append('!').end().append('?');

Find all h2 with class www, make them red, then among the found elements find elements with class test and set their font size to 30px.

byenru