0

今日、私は自分のコードを見て、自分のコードを見直したいと思っています.

$('.industry p').on('click mousenter', 'a', function(e) {
   // the code 
}

私への最初の質問は、2 つのイベントが発生した場合、それらを分離する方法が単純ではないということです。そして他の質問は次のとおりです。

$('.industry p').on('click', 'a ,b ', function(e) {
 // the code
}

上記の 2 つの質問は、私のコードを見直して、不要な部分を削除するのは賢明ではありません。直接の質問コードは次のとおりです。

$('.industry p > a').mouseenter(function() {
    var index = $(this).index()
    pall.filter(':visible').hide()
    pall.eq(index).show()
   //console.log($(this).get());
})
 $('.industry p').on('click', 'a', function(e) {
 $(this).toggleClass('choose').siblings().removeClass('choose');
 var value = $(this).text();
 $('.industry input').val(value);
 var dataId = $(this).data('id');
 $('.industry input').attr('data-id', dataId);
});

不要な部分を削除したい場合、どこから始めればよいですか?

4

0 に答える 0