How to select all elements with particular ARIA value using jQuery?

前端 未结 2 775
面向向阳花
面向向阳花 2021-01-07 19:35

Given i have a sample page that looks like this:





heading

相关标签:
2条回答
  • 2021-01-07 19:47

    The attribute selector

    [aria-controls="name1"]
    

    should work.

    Docs: http://api.jquery.com/attribute-equals-selector/

    0 讨论(0)
  • 2021-01-07 20:10

    Use something like this -

    WORKING DEMO

    var elements = $("body").find("[aria-controls='name1']");
    

    Above is for if you want to look for elements within a container eg body in this case, it can be some div also.

    --OR--

    var elements = $("[aria-controls='name1']"); 
    

    Above is for if you want to get all the elements with this attribute

    0 讨论(0)
提交回复
热议问题