passing $(this) from function to function

后端 未结 3 570
旧时难觅i
旧时难觅i 2021-01-23 12:01

I have 2 different event on different classes :

$(\'.box1\').click(function(){
$(this).find(\'something\').css(\'red\')
}

$(\'#otherId .box2\').change(function(         


        
3条回答
  •  忘了有多久
    2021-01-23 12:39

    this is a keyword so it can't be a param name

    function getDetails(el) {
        el.find(".something").css('red');
    }
    
    $('#otherId .box2').change(function () {
        getDetails($(this))
    })
    

提交回复
热议问题