For case-insensitivity we are using this ‘i’ flag). For that, we are using RegEx of JavaScript (Our RegEx is /Div/i. Now from that collection we have to find out those div elements which have title attribute value containing the substring ‘div’ irrespective of the case. Here, $(‘div’) will return a collection of all div elements having the attribute title. Now let’s see how to make the jQuery attribute contains selector case-insensitive. How to make the jQuery attribute contains selector case-insensitive? Run the above HTML Code and then click on the Click Me button and you should get the following output. In our jQuery code, our selector is matching with only the 1st div element so that is only targeted here. In the below example, notice that all the div elements have the title attribute value containing substring ‘div’ but the casing is different. Run the above HTML Code, then click on the Click Me button and you should get the following output as expected.Įxample: jQuery attribute contains selector Return $(this).attr('title').toLowerCase()= 'mysample' We are now using the filter method and for each div element in that collection, we are retrieving the attribute value, converting them to lower case using the toLowerCase built-in method, and comparing them to ‘mysample’. Now from that collection, we have to find out those div elements which have the title attribute value ‘mysample’ irrespective of the case. In the below example, $(‘div’) will return a collection of all div elements having the attribute title. We are going to change the previous example to make the jQuery attribute value selector case-insensitive. Now let’s see how to make the jQuery attribute value selector case-insensitive. How to make the jQuery attribute value selector case-insensitive? Run the above HTML code, then click on the Click Me button and you should get the following output. JQuery Case Insensitive Attribute Value Selector In the below example, notice that all the div elements have the title attribute value mysample but the casing is different. Let us see how to do this by practical example. But we have certain steps to follow to make these attribute value selectors case-insensitive. JQuery attribute value selectors are generally case-sensitive. ![]() jQuery Case Insensitive Attribute Value Selector At the end of this article, you will understand everything about the jQuery Case Insensitive Attribute Selector. ![]() Please read our previous article, where we discussed jQuery Attribute Value Selector. In this article, I am going to discuss jQuery Case Insensitive Attribute Value Selector with Examples. Data Structures and Algorithms Tutorialsīack to: jQuery Tutorials jQuery Case Insensitive Attribute Value Selector with Examples.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |