jQuery: Selecting by class and input type

前端 未结 6 1208
忘了有多久
忘了有多久 2021-01-30 05:51

I would like to select a set of elements that are both of a certain input type (say, a checkbox) and have a certain class using jQuery. However, when I try the following:

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-30 06:32

    If you want to get the inputs of that type with that class use:

    $("input.myClass[type=checkbox]")
    

    the [] selector syntax allows you to check against any of the elements attributes. Check out the spec for more details

提交回复
热议问题