Jquery 鼠标悬停功能中的单击功能在单击鼠标时禁用鼠标悬停功能
嘿,我有一个悬停函数,它使用for循环填充无序列表中的列表项。一旦列表项被生成,我需要他们有一个点击功能,该功能对应于其id末尾的数字 我使用了click函数来处理填充的列表项,但问题是一旦单击列表项,它就会禁用hover函数 单击列表项后,如何保持悬停功能正常工作Jquery 鼠标悬停功能中的单击功能在单击鼠标时禁用鼠标悬停功能,jquery,for-loop,click,hover,nested-function,Jquery,For Loop,Click,Hover,Nested Function,嘿,我有一个悬停函数,它使用for循环填充无序列表中的列表项。一旦列表项被生成,我需要他们有一个点击功能,该功能对应于其id末尾的数字 我使用了click函数来处理填充的列表项,但问题是一旦单击列表项,它就会禁用hover函数 单击列表项后,如何保持悬停功能正常工作 $(".changeProductWrapper").hover(function(){ for (var x=5; x>0; x--) { otherProductId = "#productChoice" +
$(".changeProductWrapper").hover(function(){
for (var x=5; x>0; x--) {
otherProductId = "#productChoice" + x;
if (typeof otherProducts === 'undefined') {
otherProducts = '<li class="productChoice" id="'+otherProductId+'">' + $(otherProductId).html() + '</li>';
}
else {
otherProducts = '<li class="productChoice" id="'+otherProductId+'">' + $(otherProductId).html() + '</li>' + otherProducts;
};
};
$(".productChoice").click(function(){
// function
});
});
$(.changeProductWrapper”).hover(函数(){
对于(变量x=5;x>0;x--){
otherProductId=“#productChoice”+x;
如果(其他产品的类型===‘未定义’){
otherProducts='”++$(otherProductId.html()++' ';
}
否则{
otherProducts='”++$(otherProductId.html()++' '+otherProducts;
};
};
$(“.productChoice”)。单击(函数(){
//作用
});
});
您的代码片段没有提供足够的信息来显示发生了什么。帮助人们回答问题的最好方法是在网站上发布问题的完整演示。不过,要开始,可以尝试移动$(“.productChoice”)。单击$(“.changeProductWrapper”)中的声明。悬停函数体?也是在我放置$(“.productChoice”)时。单击鼠标悬停功能之外的功能,它根本不会执行。好的,这是小提琴:---你会看到鼠标悬停功能在换成另一个产品后不再适用于该产品