How can I change a <img>
with the JS-Library Prototype?
I managed it to get the element but I couldn't change the "src":
$('item1').getElementsBySelector('img')
var imgs = $('item1').getElementsBySelector('img');
imgs.each(function(img) {
img.src = 'newSrc';
});
You can also use the setAttribute function.
var imgs = $('item1').getElementsBySelector('img');
imgs.each(function(img) {
img.setAttribute('src','newSrc');
img.setAttribute('width','100px');
});
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