javascript - set SRC of image with jquery -


i made script:

$(document).on('domnodeinserted', function(e) {   $('.stam').on('click', function() {     $('.new-image').val($(this).attr("data"));   }); }); 

this script take attribute "data" , set on "new-image" value. wont insert attribute data inside src=" " of new-image. possibile?

html:

<img class="new-image" src="--data value here--"> 

use attr() instead of val() this.

$('.new-image').attr('src', $(this).attr("data")); 

Comments