I have the following markup in a list (of repeated identical list format):
<li class="item">
<div class="outer">
<p>Some text</p>
<div class="inner">Some div text</div>
</div>
<a class="link" href="#">Link</a>
</li>
and I wish to move the a.link to between the p and the div.inner in each list item.
I am using the following script:
$("li.item a.link").each(function() {
$(this).closest("div.inner").before(this);
});
but I am just getting the error: "$(this).closest is not a function"
Why is .closest() not working... it seems to be recommended often. Is there a different way of achieving this?
Many thanks.