Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.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 单击时图像应循环_Javascript_Jquery - Fatal编程技术网

Javascript 单击时图像应循环

Javascript 单击时图像应循环,javascript,jquery,Javascript,Jquery,单击“>”按钮后,我将使用以下函数循环到下一个图像。是否可以使用相同的功能来确保在任何区域单击图像本身后,图像会移动到下一个图像 function nextPic(){ count = parseInt(count) +1; if(parseInt(count)>9) count=1; $( "#largeImg").fadeOut(0);

单击“>”按钮后,我将使用以下函数循环到下一个图像。是否可以使用相同的功能来确保在任何区域单击图像本身后,图像会移动到下一个图像

function nextPic(){
                count = parseInt(count) +1;
                if(parseInt(count)>9) 
                    count=1;
                    $( "#largeImg").fadeOut(0);
                    document.getElementById('largeImg').src="Original/0" + count + ".jpg";
                    $( "#largeImg").fadeIn(0001);
            }

使用图像控件添加单击事件

按下面的方法做

$('#largeImg').onclick(function(){
  //call you function here
});

Java不是JavaScript。为什么不调用与单击
largeImg
element@ArunPJohny:嗯,我对编程很陌生。我明白你的意思,但我不知道怎么做。我不知道如何调整它的html/css部分。您能帮助我吗?当您单击
时,如何调用
nextPic
。您还可以使用
count=(count+1)%9
,这样就不需要if语句了。或者,您可以使用
count=++count%9