Answer the question
In order to leave comments, you need to log in
How to replace an image without HTML changes?
Hello! I'm a complete JS noob and need help. Googled a lot, but apparently my knowledge is not enough. The point is this. There is an image added to html and it has no id and only class. How can I use JS or jQuery to replace the image
Here is the html snippet
div style="float: left; margin-right: 10px">
<img width="50" class="user-profile-image user-default-profile-image " src="img/default_profile_50.png"></div>
function myFoo1(){document.getElementsByClassName("user-default-profile-image")[0].id = "defimage"; }
$('#defimage').attr('src', '/fileservice/file/download/a/233337/sc/494/h/c803022e0f37921830b75a0d243e73e0.png')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question