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.
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>