• Home
  • Jobs
  • Courses
  • Questions
  • Teachers
  • For business
  • ES/EN

0

26
Views
How can I determine with one GetElementByID the unique id of different elements

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-%%');
about 1 month ago ·

Juan Pablo Isaza

1 answers
Answer question

0

You can do this with document.querySelectorAll and attribute selectors.

const content = document.querySelectorAll('[id|=inner-main-container]');
about 1 month ago · Juan Pablo Isaza Report
Answer question
Find remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.