Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript chenge img src using Jquery before it render the old Re: chenge img src using Jquery before it render the old

#129538
JohnMotylJr
Participant

Is there any dynamic reason to be replacing the images? Trying to manipulate an element like that is very tricky (if it can even be really done). What are you trying to accomplish, there may be a better alternative.

You could always do a ghetto trick

$('#js-img').hide(0);
$('#js-img').attr('src', 'new/image/');
$('#js-img').show(0);

— or —

$('#js-img').hide(0).attr('src', 'new/image').show(0);