Jump to content
Search Community

Fundamental Javascript Question about ID's and the DOM

Jim Nayzium test
Moderator Tag

Recommended Posts

Is it bad to have two elements with the same id= and be targeting them both with javascript innerHTML updates, if only ONE of them is ever visible to the page because of media queries? I am setting the display:none and display:block with media queries to make sure and I am updating their HTML simultaneously on the page with javascript with the same script. But I only ever have ONE of them showing to the page. I have it all working but was curious if I should be writing the extra lines to update two div_id's innerHTML since they are "in the running code of the page" but are not "displaying" etc...

 

The only time I feel like it's an issue is when someone resizes their screen live while viewing the page and I would need the javascript to re-run. But other than that, I was just wondering what best-practices dictate in this case above?

 

Sorry for the fairly newb/javascript level question.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...