Reputation: 521
I'm using zoom which is a simple jQuery plugin for image zooming, as seen on Medium.
It requires adding a data-action="zoom"
to all the <img>
tags to work.
Here's my Fiddle.
I want it to work with all the images in a web page by a using a js code that applies the attribute to all <img>
tags.
Upvotes: 0
Views: 70
Reputation: 3065
What you can do is use attribute setter .attr(attributeName, value)
.
$('img').attr("data-action","zoom")
see in action
Upvotes: 3
Reputation: 8101
Add like:
$( "img" ).each(function( index ) {
$(this).attr("data-action","zoom")
});
Upvotes: 2