Mixing Attribute Selector $("selector[attribute=value]")

You can mix jQuery attribute selector with other type of selectors such as class selector. For example to select element <input type='text'> you can use $('input[type=text]')


e.g. $("div[name='apple']")

$("selector[attribute=value]") we can mix other type of selectors e.g. id or class selectors with attribute selector.

For example, $("div[name='apple']") will find all <div name='apple'>.
<div name='apple'>
<div name='orange'>
<p name='apple'>

Code: Find all elements where first selector is class='circle' & attribute selector is name='apple'

//CSS classes
.circle{ ... }
.square{ ... }

<div class="circle" name="apple">apple</div>
<div class="square" name="apple">apple</div>
jQuery code
$(".circle[name='apple']"); // selects elements where class='circle' & name='apple'

jQuery selector $("selector[attribute=value]")