I use a lightbox that requires a specific tag inside the link. I don't want to edit every post, so I'm trying to do this automatically using jquery.
HTML
<div class="wrapper">
<a href="imagelink.png">Image</a>
</div>
Js
$(document).ready(function() {
$('.wrapper a').each(function(){
$(this).parent().attr('data-lity');
});
});
The result should be
<div class="wrapper">
<a href="imagelink.png" data-lity>Image</a>
</div>
JSfiddle http://jsfiddle.net/c2RvG/31/
source
share