Comma separated list of selectors?

前端 未结 4 1028
一向
一向 2020-12-15 17:59

I\'m refactoring some code at the moment and have come across a selector:

jQuery(\"tr\",\"#ctl00_MainContent_MyUserControl\").each(function(i,row) { ... }
         


        
4条回答
  •  我在风中等你
    2020-12-15 18:30

    This selector selects all tr elements inside an element with id ctl00_MainContent_MyUserControl. It is exactly the same as your second example.

    The second parameter provides a context for the first parameter. There are better use cases for this syntax, for example:

    function(el) {
        $('tr', el).each(...);
    }
    

    Where el is some element on your page. In this case, you can't use the second syntax form.

提交回复
热议问题