How to Select an Element based on the Value of its Attribute


You want to selects elements that have the specified attribute with a value exactly equal to a certain value.

Let's say you have an form input element defined as follows:

<input id="txtName" class="myStyle" type="text" size="12" maxlength="20" />

To select element based on its size or maxlength attributes value you can use:

$("input[size='12']"); 

$("input[maxlength='20']");

 

 

About author


User avatar

Waqas Anwar

Founder of EzzyLearning.com, Senior Consultant, Microsoft .NET and Web Technologies

Comments