Select multiple jQuery objects with .add()

前端 未结 3 1463
慢半拍i
慢半拍i 2020-12-03 10:16

Does the .add() method allow selecting multiple objects in one go instead of adding one at a time?

one.add(two).add(three).add(four).on(\"click\", function()         


        
3条回答
  •  清歌不尽
    2020-12-03 10:37

    You could put them into an array like this

    var k = [one,two,three,four]
    
    $.each(k,function(){
      $(this).click(function(){
         //Function here
       });
    });
    

提交回复
热议问题