简体   繁体   中英

jQuery find all elements with certain attribute and get the value of it

I need to get values of every existing 'ajaxify' attribute on the page.

$('[ajaxify]')

This gets me 361 objects. How to get the values?

To get all value as an array, use map() , attr() and get() methods

$('[ajaxify]').map(function() {
  return $(this).attr('ajaxify')
}).get()

FYI : Always try to use data-* (eg : data-ajaxify ) for custom attribute, since it's the standard way to use custom attribute. In than case you can use data() method to get attribute value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM