for my different elements i have the same class tag with only different ending. My html elements;
id="inner-main-container-one"
id="inner-main-container-two"
id="inner-main-container-three"
My code define in js is:
var content = document.getElementByID('inner-main-container-one');
var contentone = document.getElementByID('inner-main-container-two');
var contenttwo = document.getElementByID('inner-main-container-three');
How can i determine the unique id with one define ? Like this:
var content = document.getElementByID('inner-main-container-%%');
Juan Pablo Isaza
You can do this with document.querySelectorAll and attribute selectors.
const content = document.querySelectorAll('[id|=inner-main-container]');