Pick up DIV through a custom attribute

Asked

Viewed 37 times

1

I have several DIVs as the code below.

  <div class="col-md-10" ordained-field="0"></div>

How do I get them all by the attribute I created ordained-field

1 answer

1


I just needed to define the type of element I want to bring and my custom attribute between brackets:

console.log($('div[ordained-field]'))

I also found a search through a custom attribute with values:

$('div[ordained-field="1"]')

  • just change "ordained-field" to "data-ordained-field" to be a valid property in html.

  • https://www.w3schools.com/tags/att_global_data.asp

Browser other questions tagged

You are not signed in. Login or sign up in order to post.