Looping through ids's

Hi ,

I have a doubt I am working on small project and I want to loop through all the document.getElementById() is it possible.Please help me.

As the identifier is a unique identifier, only one is supported.

I recommend that you use a classname instead when you need to identify multiple elements, and loop through document.querySelectorAll(".classname") instead.

Thank you so much sir.

I have a nav bar with menu items each with specific ids. and a multiple div tags, and i want to match each menu item with a div so if I click on "home " menu that particular div tag should be activated . How is it possible. can you Please explain and this is the project I am working now.

Thank you.

That’s looks to be a CSS solution that you’re needing.
A good solution is ID Your Body For Greater CSS Control and Specificity

For further CSS assistance I recommend that you contact our CSS people in the HTML & CSS forum.

Thank you so much

Hi Paul.

Is it possible through script rather than css, I wanted to implement onepage scroll with pure js without any libraries.

Scripting is a much worse solution, to the point where it is actively discouraged when much better solutions exist.

With a one-page scroll without any libraries, you are going to need quite a lot of JavaScript.
Do you know much JavaScript? And if so, what have you done towards solving things?

I interested in learning DOM scripting and worked as a front end developer , so I have a little knowledge in js.

We don’t tend to write the complete code that people need, because otherwise all of our spare time will be spent working for people at no pay. That is not a viable situation.

We can either help with existing code that you have, or give direction to how you can learn more about coding in ways that are relevant to what you require.

How would you like to take things from here?

I am sorry.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.