Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript onClick功能在移动设备上不起作用_Javascript_Html_Function_Onclick - Fatal编程技术网

Javascript onClick功能在移动设备上不起作用

Javascript onClick功能在移动设备上不起作用,javascript,html,function,onclick,Javascript,Html,Function,Onclick,我在左边有一个图像,在右边有几个图标。当有人点击图标时,左侧的图像将发生变化。 在台式机中工作,但在移动设备中不工作 这是我的代码,希望你能帮助我 <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/

我在左边有一个图像,在右边有几个图标。当有人点击图标时,左侧的图像将发生变化。 在台式机中工作,但在移动设备中不工作

这是我的代码,希望你能帮助我

<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>

健身房

温泉

函数divPic(){ document.getElementById('div1').innerHTML=“”; } 功能健身房(){ document.getElementById('div1').innerHTML=“”; } 函数spa(){ document.getElementById('div1').innerHTML=“”; }
在document.ready函数中没有包含JavaScript代码

    $(document).ready(function(){
           Your_code_here
     }

希望这能起作用

jQuery并不是解决所有问题的解决方案,尤其是当它是一项可以用普通JavaScript轻松完成的任务时P