HTML
<a href="/home/" id="one"><img src="images/img1.png"/></a>
JS
<script>
$(document).ready(function(){
$('#one').
});
</script>
How to change anchor tag to <a href="/home/" id="one"><img src="images/img2.png"/></a>
?
HTML
<a href="/home/" id="one"><img src="images/img1.png"/></a>
JS
<script>
$(document).ready(function(){
$('#one').
});
</script>
How to change anchor tag to <a href="/home/" id="one"><img src="images/img2.png"/></a>
?
Use the following code:
$("#one img").prop("src", "images/img2.png");
It will change the src
property of <img>
element to "images/img2.png"
.
Try:
$(document).ready(function(){
$('#one').on('click',function(e){
$(this).children('img').attr('src','images/img2.png');
e.preventDefault();
});
});