I'm using a lightbox that requires a specific tag inside the link. I don't really 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() {
// Scan classes
$('.wrapper a').each(function(){
// Apply tag
$(this).parent().attr('data-lity');
});
});
Result should be
<div class="wrapper">
<a href="imagelink.png" data-lity>Image</a>
</div>
JSfiddle http://jsfiddle.net/c2RvG/31/
script
$('.wrapper a').attr('data-lity', '');
You don't need to iterate. Jquery does it for you. Just set the attribute.
Hope it helps. Cheers!
This will do a trick
Jquery
$(document).ready(function() {
// Scan the webpage for all class names of 'thumb' that is seen.
$('.wrapper a').attr('data-lity', '');
});
DEMO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With