var tm = $(".status-load > div");
var _this=$(this);
console.log($.index(tm));
tm.each(function(idx){
tm.eq(idx).on('tap',function(){
_this.addClass("load-chk")
.siblings().removeClass("load-chk")
.end();
if(_this.index()==0){
orderLists();
}else if(_this.index()==1){
orderUndone();
}else if(_this.index()==2){
orderUndo();
}
});
});
上面代码需要实现一个效果,就是被点击的元素添加样式的时候去判断元素的下标,如果下标相等,执行对应方法。
现在报了个错误
对这个具体事例看的不是很懂!
var _this = $(this);
从Error Message 来看似乎是 $(this)
所指向的 element 没有 parentNode 造成的(具体原因要和 context 结合才能排查)