Jquery multiple selectors with this

前端 未结 1 720
自闭症患者
自闭症患者 2020-12-21 16:53

I\'ve searched but can\'t find how to do this. I\'m trying to make the elements with comment-modbox inside this hide and show:

$(\         


        
相关标签:
1条回答
  • 2020-12-21 17:34

    try this (jQuery("selector", context)...)

    $('.comment-wrapper').each(function (index) {
    
        $('.comment-modbox', this).mouseover(function () {
            $(this).show();
        });
    
        $('.comment-modbox', this).mouseout(function () {
            $(this).hide();
        });
    });
    

    Second choice:

    $('.comment-wrapper').each(function (index) {
    
        var wrapper = this; 
    
        $('.comment-modbox', wrapper)
            .mouseover(function () {
                $(this).show();
            })
            .mouseout(function () {
                $(this).hide();
            });
    });
    
    0 讨论(0)
提交回复
热议问题