We could simply select elements via jQuery with an attribute selector (having the syntax, [attribute="value"]). The attribute selectors provide a very powerful way to select elements. How to check if an element has a class in jQuery? You can try to run the following code to learn how to use hasAttribute() method: We make use of First and third party cookies to improve our user experience. How to check if onClick exists on element in jQuery? OK, but the point is that what you typed in your example above won't work. 2 Code Answers . How to append an element before an element using jQuery? JS HTML Edit in JSFiddle Alternatively, you can use the Has Attribute Selector [name] to select elements having the specified attribute. The .filter() method will match an HTML element using a CSS selector. Surface Studio vs iMac - Which Should You Pick? set custom data attribute jquery. how to get the attribute values of the table row using jquery? jquery get element by data attribute. jquery attributes. The hasAttribute () method accepts an argument that specifies the name of the attribute that you want to check. Check a Radio Button Using JavaScript or jQuery, Create, Read and Delete Cookies Using JavaScript and jQuery, Remove, Add, and Select the Options of a Select Tag Using jQuery, Find a Data Attribute Using a CSS Attribute Selector, Select the First Option of the Dropdown Using jQuery. Has Attribute Selector [name] Categories: Selectors > Attribute attributeHas selector Description: Selects elements that have the specified attribute, with any value. First, the parent

jquery check if element has data attribute