Wildcards in jQuery selectors

前端 未结 6 2345
逝去的感伤
逝去的感伤 2020-11-22 06:18

I\'m trying to use a wildcard to get the id of all the elements whose id begin with \"jander\". I tried $(\'#jander*\'), $(\'#jander%\') but it doe

6条回答
  •  遇见更好的自我
    2020-11-22 07:08

    To get all the elements starting with "jander" you should use:

    $("[id^=jander]")
    

    To get those that end with "jander"

    $("[id$=jander]")
    

    See also the JQuery documentation

提交回复
热议问题