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

java - How to specify maven bin in eclipse maven plugin? -

Error while updating a record in APEX screen -

c++ - In an add-in in Excel, written in C(++), how does one get the name of the function which called into the addin? -