FindByAttributeValue("Attribute-Name", "Attribute-Value");
P. S. si usted sabe exactamente del tipo de elemento, se agrega 3er parámetro (es decir div, a, p ...etc...
):
FindByAttributeValue("Attribute-Name", "Attribute-Value", "div");
pero al principio, defina esta función:
function FindByAttributeValue(attribute, value, element_type) {
element_type = element_type || "*";
var All = document.getElementsByTagName(element_type);
for (var i = 0; i < All.length; i++) {
if (All[i].getAttribute(attribute) == value) { return All[i]; }
}
}
P. S. actualizado por recomendaciones de comentarios.
Duplicar si usted está buscando un Jquery Sol: http://stackoverflow.com/questions/696968/jquery-v1-3-2-find-element- por atributo – Rajat
¿Puede actualizar la respuesta aceptada a la solución moderna, la respuesta de Wojtek? –