What is the difference between $.each(selector) and $(selector).each()

前端 未结 8 869
夕颜
夕颜 2020-12-07 12:59

What is the difference between this:

$.each($(\'#myTable input[name=\"deleteItem[]\"]:checked\').do_something());

and this:



        
8条回答
  •  时光取名叫无心
    2020-12-07 13:35

    The first will run the callback function to the elements in the collection you've passed in, but your code is not syntactically correct at the moment for it.

    It should be:

    $.each($('#myTable input[name="deleteItem[]"]:checked'), do_something);
    

    See: http://api.jquery.com/jQuery.each/

    The second will run the function on each element of the collection you are running it on.

    See: http://api.jquery.com/each/

提交回复
热议问题