You can loop through all the attributes and check if they contain the string you are looking for. With:
<div customAttr="12" title="me"></div>
<div anotherAttr="Bear"></div>
<div yetAnotherAttr="Elephant"></div>
You could use:
var m = /another/i; //will look for 'another' in the attribute name (i-flag for case-insensitive search)
$('div').each(function(){
var $this = $(this);
$.each(this.attributes,function(){
if (this.name.match(m)){
$this.addClass('selected'); //either select the matching element
$this.text(this.name + ' : ' + this.value); //or use its custom-attribute's value
}
});
});
See a fiddle