I want to make id=”a” element div to be the second div in the div.b element.
And I want to how to make id=”a” element div to be the last div in the div.b element.
Here is the code:
<div class='b'>
<div>a</div>
<div>a</div>
<div id="a">I want to moderate this div </div>
<div>a</div>
</div>
The result I want to achieve is:
<div class='b'>
<div>a</div>
<div id="a">I want to moderate this div</div>
<div>a</div>
<div>a</div>
</div>
And:
<div class='b'>
<div>a</div>
<div>a</div>
<div>a</div>
<div id="a">I want to moderate this div</div>
</div>
The after function will insert content after what’s selected.
This selects the first div under your
<div class="b", then inserts your<div id="a"after that, thereby makingathe second div underb.To make
abe the last div underb, you’d find the currently last div underb, and insertaafter thatTo make
afirst, you’d use the before function:Finally, per mu’s good comment, I’ll mention the eq function, which would allow you to select a child div of any index
So now
awould be third.