Reputation: 591
at the the moment i'm doing this:
$('.Zoom').empty()
$('.Zoom').prepend('<img id="zoom_07" src="Zoom.png" data-zoom-image=' + zoomImageDataUri + '/>');
What I want to do is just change the "data-zoom-image=" part. How would I do this, something like:
document.getElementById("zoom_07")."data-zoom-image=""+ zoomImageDataUri +";
Upvotes: 0
Views: 88
Reputation: 283313
First, you don't have to worry about escaping/building HTML strings if you use jQuery to create the element:
$('.Zoom').empty().prepend($('<img>',{id:'zoom_07', src:'Zoom.png','data-zoom-image':zoomImageDataUri});
Second, I'm not quite sure what you're trying to do with the 2nd bit; your syntax is way off. Try this:
$('#zoom_07').attr('data-zoom-image',zoomImageDataUri);
You may also utilize the $.data
method, but I don't think it updates the attribute, just jQuery's internal representation of it.
Upvotes: 2