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