HTML
<a href="/home/" id="one"><img src="images/img1.png"/></a>
JS
<script>
$(document).ready(function(){
$('#one').
});
</script>
如何将锚标签更改为<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>
如何将锚标签更改为<a href="/home/" id="one"><img src="images/img2.png"/></a>
?
使用以下代码:
$("#one img").prop("src", "images/img2.png");
它将元素的src
属性更改为.<img>
"images/img2.png"
尝试:
$(document).ready(function(){
$('#one').on('click',function(e){
$(this).children('img').attr('src','images/img2.png');
e.preventDefault();
});
});