How to use querySelectorAll only for elements that have a specific attribute set?

后端 未结 3 424
深忆病人
深忆病人 2020-12-22 20:57

I\'m trying to use document.querySelectorAll for all checkboxes that have the value attribute set.

There are other checkboxes on the page t

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-22 21:25

    Extra Tips:

    Multiple "nots", input that is NOT hidden and NOT disabled:

    :not([type="hidden"]):not([disabled])
    

    Also did you know you can do this:

    node.parentNode.querySelectorAll('div');
    

    This is equivelent to jQuery's:

    $(node).parent().find('div');
    

    Which will effectively find all divs in "node" and below recursively, HOT DAMN!

提交回复
热议问题