Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there any way to call a specific element without using class or id

I’m trying to manipulate all my HTML tags this code.
I listed them like so:

var elements = document.getElementsByTagName("*")

And I would like to manipulate the variable
elements and modify the tags in it.

Thing is, I need to add an ID or some sort of class on all of them.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Is there any way other than having to add an id or classname?
Is there any special id given to the tags by default or something?

Thanks a lot.

>Solution :

You can assign data-id and a value to it

you can access it in jquery using

const value = $(event.currentTarget).attr('data-id')

example:

<button class="submitButton" id="btn1" data-id="1">Submit</Button>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading