0

嘿,我有一个悬停函数,它使用 for 循环填充无序列表中的列表项。生成列表项后,我需要它们具有与其 ID 末尾的数字相对应的单击功能。

我让单击功能适用于填充的列表项,但问题是一旦单击列表项,它就会禁用悬停功能。

单击列表项后保持悬停功能正常工作的任何想法?

$(".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

});

});
4

0 回答 0