Select element with multiple attributes in jQuery

Selecting element with two or more attributes in your html page is not a trivial task. It’s just a very simple line of jQuery selector when it comes to select element with multiple attributes. So let us see what is that.

HTML

Our page consists of the following html:

Select element with multiple attributes

So the jQuery selector to select all anchor elements with href="zoom" and rel="nature" attributes would be:

Quite simple!! In general we can select element with multiple attributes in jQuery in the following common syntax:

$('tag[attribute1="value1"][attribute2="value2"]')

You Might Interested In

Leave a Reply

Enclose a code block like: <pre><code>Your Code Snippet</code></pre>.