我左边有一个图像,右边有几个图标。当有人点击图标时,左侧图像会发生变化。 在桌面工作但不在移动设备。
这是我的代码,希望你能帮助我
<div class="container container-amenidades-bloque2">
<div class="col-sm-6 img-amenidades" id="div1">
<img src="http://www.eqia.mx/wp-content/uploads/2018/06/amenidades.img-min.png"/>
</div>
<div class="col-sm-6 container-all-icons-amenidades">
<div class="container-icon-amenidades" onclick="gym()" id="icon-gym">
<img src="http://www.eqia.mx/wp-content/uploads/2018/06/iconohome-6.png">
<p>Gym</p>
</div>
<div class="container-icon-amenidades" onclick="spa()" id="icon-spa">
<img src="http://www.eqia.mx/wp-content/uploads/2018/06/iconohome-6.png">
<p>Spa</p>
</div>
</div>
</div>
<script>
function divPic() {
document.getElementById('div1').innerHTML = "<img src='https://upload.wikimedia.org/wikipedia/commons/2/2f/MRT_Singapore_Destination_1.png'>";
}
function gym() {
document.getElementById('div1').innerHTML = "<img src='https://upload.wikimedia.org/wikipedia/commons/1/10/MRT_Singapore_Destination_2.png'>";
}
function spa() {
document.getElementById('div1').innerHTML = "<img src='https://upload.wikimedia.org/wikipedia/commons/2/2f/MRT_Singapore_Destination_1.png'>";
}
</script>
答案 0 :(得分:0)
您没有在document.ready function
中附上JavaScript代码 $(document).ready(function(){
Your_code_here
}
希望这有效