I want to get all anchor elements on my page where the attribute “rel” exists and where it has the value “no”.
How can I do this using jQuery?
I’ve tried something using the find method
var list = [];
$(parentElement).find('[rel]').each(function(index){
if (this.attr("rel")) list.push(this);
});
Can this be done easier?
Use the element selector
acombined with the attribute equals selector[rel=no]:If you want only anchor elements that are links (not bookmarks), also use the has attribute selector
[href]: