0

I am new to javascript. Let's say I have a block

<div class="nav">
  <div id="rectangle" class="rectangle">
    Content...
  </div>
</div>

And I am using this block in some script

document.getElementById('navShareLink');

But now I want to add another one to the nav block, let's say

<div class="nav">
  <div id="rectangle" class="rectangle">
    Content...
  </div>

  <div id="to-top" class="to-top">
    Content...
  </div>
</div>

The question is, can I use two blocks at once in this line, like

document.getElementById('rectangle', 'to-top');

If not, what are the options?

Mustafa Kemal
  • 762
  • 1
  • 5
  • 11
  • There is a good explanation of this topic [here](https://stackoverflow.com/questions/14408891/getelementbyid-multiple-ids). – Kris West Dec 06 '21 at 09:28
  • 2
    Does this answer your question? [GetElementByID - Multiple IDs](https://stackoverflow.com/questions/14408891/getelementbyid-multiple-ids) – Kris West Dec 06 '21 at 09:28
  • It has constant lookup speed anyway, since the ids are like the hashes in a hashmap. So It's fine to call it twice, performance wise. – The Fool Dec 06 '21 at 13:46

0 Answers0