Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.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
为jquery幻灯片放映添加onclick事件_Jquery_Slideshow - Fatal编程技术网

为jquery幻灯片放映添加onclick事件

为jquery幻灯片放映添加onclick事件,jquery,slideshow,Jquery,Slideshow,我正在使用Aaron Vanderzwan基于Jquery循环的幻灯片放映最大化,但在向幻灯片添加onclick事件时遇到了一些问题。在研究stack exchange上的解决方案时,我遇到了一个“点击”z索引定位div的解决方案,并将指针事件:noneCSS属性添加到我的设置中。这是我正在制作的幻灯片的一个例子。我的问题是在将以下jquery添加到页面时遇到问题。感谢您的指导。提前谢谢你 //The following was taken from the maximage forum's.

我正在使用Aaron Vanderzwan基于Jquery循环的幻灯片放映最大化,但在向幻灯片添加onclick事件时遇到了一些问题。在研究stack exchange上的解决方案时,我遇到了一个“点击”z索引定位div的解决方案,并将
指针事件:none
CSS属性添加到我的设置中。这是我正在制作的幻灯片的一个例子。我的问题是在将以下jquery添加到页面时遇到问题。感谢您的指导。提前谢谢你

//The following was taken from the maximage forum's.

var $maximage = $('#maximage');

// Trigger Maximage
$maximage.maximage();

// Capture click on maximage's children
$maximage.children().on('click', function(){
// Retrive our URL (set in data-href attribute on img tags)
var url = $(this).data('href');

// If our URL is set, open a new window with that URL
//    You can certainly use window.location here too
if(url.length > 0){
    window.open(
        url, // <- This is what we set with the data-href attribute
        '_blank' // <- This is what makes it open in a new window.
    );
}
});
//以下内容摘自maximage论坛。
var$maximage=$(“#maximage”);
//触发最大值
$maximage.maximage();
//捕捉点击maximage的孩子
$maximage.children().on('click',function()){
//检索我们的URL(在img标签的data href属性中设置)
var url=$(this.data('href');
//如果设置了URL,请使用该URL打开一个新窗口
//你当然也可以在这里使用window.location
如果(url.length>0){
打开窗户(

url,//如果您与inspector一起检查,您可以看到在启动JS后,图像上不再有数据属性。问题在于您正在进行的所有背景工作。不确定maximage如何工作,但似乎

background size
(或者,如果您不使用,则无所谓)将图像转换为.mc image div中的背景图像。data href也添加到div中(允许您单击它)。 如果您现在使用

cssBackgroundSize: false, // We don't want to use background-size:cover for our custom size
背景图像div将再次转换为图像,并删除数据attr


因此,要么不要使用cssBackgroundSize:false并使div.mc图像可点击(只需删除data href调用中的子项),要么采取另一种方式

谢谢gulty!这非常有用。用一个可用的jsfiddle更新了我的问题,再次感谢!