Echivalentul hasAttr() in jQuery
In jQuery nu exista functia hasAttr(), asa ca iata cum puteti obtine aceasta functioenalitate.
Preia atributul si verifica valoarea
var attr = $(this).attr('name'); // For some browsers, `attr` is undefined; for others, `attr` is false. Check for both. if (typeof attr !== typeof undefined && attr !== false) { // Element has this attribute }
In JavaScript nativ
$(this)[0].hasAttribute("name"); jQObject[0].hasAttribute("name");
Filtrare selectie
$(this).is('[name]'); $(this).filter("[name='choice']");