Adding an ID to element

jimwartnick
4 Posts
jimwartnick posted this 08 May 2025
Ask a Question

Is there a way to add an "id" attribute to an element? If not, in today's day and age with HTML, JAVASCRIPT, etc. it should be added. Almost nothing is static today in web design, and html/javascript needs to be able to manipulate elements by "id" or "name". I can't image it would be too challenging adding that to the UI as everything else is readily available.

Thanks.

-Jim

Vote to pay developers attention to this features or issue.
1 Reply
Order By: Standard | Newest
Support Team
Support Team posted this 08 May 2025

Hello Jim,

Thanks for contacting us.

We recommend using a class instead of an ID here, as most elements already have an ID assigned, and since an ID must be unique, it's better to use more flexible selectors when working with multiple elements.

You can access the element like this:

document.getElementsByClassName("myAddedClassName") - returns all elements with that class name.

document.querySelector(".myAddedClassName") - returns the first element with that class name.

document.querySelectorAll(".myAddedClassName") - returns all elements with that class name (as a NodeList).

Feel free to choose the one that fits your use case best! If you have any other questions or need further assistance, please let us know.
...................................................
Sincerely,
George.
Nicepage Support Team

Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1
Follow us on Facebook: http://facebook.com/nicepageapp

You must log in or register to leave comments