Code: 14
Pegar elemento por nome especifico de atributo.
by Lucas Fontes Gaspareto
HTML
<input data-2015-1="5">
<input data-2013-1="10">
<input data-2015-2="1">
<input data-2015-3="7">
<input data-2015-4="45">
JavaScript
function getByAttr(regx) {
Array.prototype.forEach.call(document.getElementsByTagName('*'), function(elem) {
Array.prototype.forEach.call(elem.attributes, function(attr) {
if(attr.name.indexOf('data') != -1 && attr.name.match(regx)) {
console.log(elem);
}
});
});
}
getByAttr(/2013/);