Multiple selector chaining in jQuery?

前端 未结 7 914
迷失自我
迷失自我 2020-11-29 03:23

Normally when I use a class as a selector I try to use an \"id\" selector with it so it does not search through the entire page but only an area where the class would be.

7条回答
  •  我在风中等你
    2020-11-29 03:51

    like:

    $('#Create .myClass, #Edit .myClass').plugin({ 
        options: here
    });
    

    You can specify any number of selectors to combine into a single result. This multiple expression combinator is an efficient way to select disparate elements. The order of the DOM elements in the returned jQuery object may not be identical, as they will be in document order. An alternative to this combinator is the .add() method.

    • Multiple Selector
    • Add method

提交回复
热议问题