javascript - Change a value in an img -
at the moment i'm doing this:
$('.zoom').empty() $('.zoom').prepend('<img id="zoom_07" src="zoom.png" data-zoom-image=' + zoomimagedatauri + '/>');
what want change "data-zoom-image=" part. how this, like:
document.getelementbyid("zoom_07")."data-zoom-image=""+ zoomimagedatauri +";
first, don't have worry escaping/building html strings if use jquery create element:
$('.zoom').empty().prepend($('<img>',{id:'zoom_07', src:'zoom.png','data-zoom-image':zoomimagedatauri});
second, i'm not quite sure you're trying 2nd bit; syntax way off. try this:
$('#zoom_07').attr('data-zoom-image',zoomimagedatauri);
you may utilize $.data
method, don't think updates attribute, jquery's internal representation of it.
Comments
Post a Comment