Finding element(s) by data attribute = variable using jQuery
Finding element(s) by data attribute = variable using jQuery
Student
I am Utpal Vishwas from Uttar Pradesh. Have completed my B. Tech. course from MNNIT campus Prayagraj in 2022. I have good knowledge of computer networking.
Sure, here is how to find elements by data attribute = variable using jQuery:
JavaScript
The
elementsvariable will contain an array of all the elements with the data-attribute of "variable". Theeach()method will loop through the elements and execute the function for each element.Here is an example of how to use this code:
HTML
This code will create two div elements, one with the data-attribute of "variable" and one with the data-attribute of "other-variable". The
each()method will loop through the elements and print the element to the console.