I want to move a div div #injectfrom its original position to the right after the 7th paragraph #mw-content-text.
So far I have this $('#inject').insertAfter('#mw-content-text > p:nth-child(7)');one that moves the div #injectto the right after the 7th element inside #mw-content-text, only if this 7th elite is <p>, if it doesn’t do anything else.
For example, if an article has the following structure, it works (since the 7th elite is <p>)
<div id="mw-content-text">
<table></table>
<h2></h2>
<p></p>
<p></p>
<p></p>
<h2></h2>
<p></p>
/* div #inject is injected here */
<p></p>
<h2></h2>
...
If the article looks like this, on the other hand (were there 7th elites, this <h2>), then it does nothing
<div id="mw-content-text">
<table></table>
<h2></h2>
<p></p>
<p></p>
<h2></h2>
<p></p>
<h2></h2>
<p></p>
<p></p>
<h2></h2>
<p></p>
...
- , ? 7- <p> # mv-content-text 7- , a <p>?