我对最后一个功能有疑问。目标是,当我单击“suiv”div 时,脚本会使用我在 suiv div 之外的 div“.crea”开始循环。
但是,循环 this.div.find('.crea').each(function){}
不起作用。
$(document).ready(function(){
s = new slider(".galerie");
});
var slider = function (id) {
var self = this;
this.div = $(id);
this.nb = 0;
this.index = 0;
this.div.find(".crea").each(function () {
self.nb++;
//alert($(this).css("z-index"));
});
alert(this.nb);
this.index = 0;
this.suiv = this.div.find(".suiv");
this.prec = this.div.find(".prec");
this.suiv.click(function () {
this.div.find(".crea").each(function () {
//self.index=parseInt($(this).css("z-index"));
alert("wesh2");
}
});
}
最佳答案
将 find('crea')
更改为 parent('crea').children()
它将起作用。
find
只会向下。
关于javascript - 从函数引用的 div 中访问一个 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31813307/