How can I select an element with multiple classes in jQuery?

前端 未结 13 2770
一向
一向 2020-11-22 00:51

I want to select all the elements that have the two classes a and b.


So, only the e

13条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 01:06

    Group Selector

    body {font-size: 12px; }
    body {font-family: arial, helvetica, sans-serif;}
    th {font-size: 12px; font-family: arial, helvetica, sans-serif;}
    td {font-size: 12px; font-family: arial, helvetica, sans-serif;}
    

    Becomes this:

    body, th, td {font-size: 12px; font-family: arial, helvetica, sans-serif;}
    

    So in your case you have tried the group selector whereas its an intersection

    $(".a, .b") 
    

    instead use this

    $(".a.b") 
    

提交回复
热议问题