jQuery attribute name contains -


i'm trying target attributes names contains word & not in kind of way you're thinking.

lets have:

<div data-foo-bar="hello"></div> 

how can target elements have 'data-foo' in attribute name?

i don't think can target attribute names same way target attribute values. can, however, use .filter() efficiently:

$('div').filter(function() {   (var property in $(this).data()) {     if (property.indexof('foobar') == 0) {       return true;     }   }    return false; });​ 

notice data-foo-bar has been converted foobar.

demo: http://jsfiddle.net/tyj49/3/


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -