I have this jQuery:
$(this).parent().parent().find(".license_tooltip").stop(true, true).fadeIn(200);
The $(this)
object is nested within two div
s like this:
<div> <div> <a href="">$(this) object</a> </div> <div> <a href="">object to fade in</a> </div> </div>
Can someone point me in the right direction to making my jQuery more streamlined? The structure presented above is replicated multiple times, so using classes and IDs is impossible.
You could use the
.parents( [ selector ] )
here is a linkIt will traverse more than one parent up.
You can use a class (or any other selectable attribute) and
.closest()
to claim to the parent you want, like this:And for the script:
use
parents()