Find HTML based on partial attribute

Posted by Kirean on Stack Overflow See other posts from Stack Overflow or by Kirean
Published on 2012-08-30T14:19:04Z Indexed on 2012/08/30 15:38 UTC
Read the original article Hit count: 273

Is there a way with javascript (particularly jQuery) to find an element based on a partial attribute name?

I am not looking for any of the selectors that find partial attribute values as referenced in these links:

but more something along the lines of

<div data-api-src="some value"></div>
<div data-api-myattr="foobar"></div>

and

$("[^data-api]").doSomething()

to find any element that has an attribute that starts with "data-api".

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery