Selecting elements whose attribute value contains certain characters only in between using jQuery.

Vishalneeraj-24503
Posted by Vishalneeraj-24503 under jQuery category on | Points: 40 | Views : 641
To select elements whose attribute value contains certain characters only in between,we can use "~=" operator.
For Example:-
<input id="txtName" type="text" data-id="txtName" />
<input id="FirstNameLast" type="text" data-id="Name txt" />
<input type="button" value="Button" id="btnTest" />

<script>
$(function()
{
$("input[data-id~='Name']").css("border","1px solid blue");
});
</script>

Comments or Responses

Login to post response