I'm trying to create an array of element attribute values where the attribute name ends with the string "toselect". I have lots of these elements on the page but I only want the values for the element I clicked on. I don't know if jquery .attr() function takes any wild card characters. I'm using jquery but I will also be happy with a pure javascript anwser
I know this doesn't work but I need something similar.
var attrs[] = $(this).attr('*toselect');
The html looks like this
<div class="someclass" data-firsttoselect="somevalue1" data-secondtoselect="somevalue2" data-thirdtoselect="somevalue3"></div>
So the array 'attrs' should contain {somevalue1, somevalue2, somevalue3}
data-*attributes, and not your own made up invalid attributes ?data-*attributes instead.