How do I select elements with attributes that start with something?

Many frameworks implement their own attributes ( ng-

, v-

, bind-

etc.). Is there a way to select items with attributes starting on some line? (without traversing all elements and their properties)

+3


source to share


1 answer


You can use these methods for this:



  • Padolsey special filter (see Padelsey regexp: filter )

    Let's say you have <div class="exampleDiv">

    you can catch a div element with $("div:regex(class, exa.*)")

    . (NB: exa.*

    is your regex ...)

  • Native jQuery selectors

    $('[id^=start]')

    matches elements with an id attribute starting at the beginning $('[id$=end]')

    matches elements with an id attribute ending at the end

+2


source







All Articles