Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

can same span id display more than 1x?

Contributor ,
Oct 05, 2015 Oct 05, 2015

hi all,

is there a way to have the span id display more than 1x (the 1st shows up but not the next one) without extra javascript document.getElementById('name2***').textContent = "bob";?

html....

1 - the name is <span id="name"></span>


this doesn't show 2nd time

2 - again the name is <span id="name"></span>

<script>

document.getElementById('name').textContent = "bob";

</script>

938
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 05, 2015 Oct 05, 2015

ID = a unique identifyer.  It doesn't matter what it is used on -- div, span, p etc...  It can be used only 1 x per page.  That's absolute & written in stone.

Translate
Community Expert ,
Oct 05, 2015 Oct 05, 2015

ID = a unique identifyer.  It doesn't matter what it is used on -- div, span, p etc...  It can be used only 1 x per page.  That's absolute & written in stone.

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 06, 2015 Oct 06, 2015

Thanks Nancy - good to know

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 05, 2015 Oct 05, 2015

HTML ID's can only be used once per page.

Not sure what you're attempting exactly, but maybe this would work better with a class...HTML DOM getElementsByClassName() Method

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 05, 2015 Oct 05, 2015

Of course that will invoke all of the same classes to fire at the same time; not separately.

Nancy O.

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 24, 2015 Dec 24, 2015
LATEST

Thanks you Nancy & Jon - very helpful!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 06, 2015 Oct 06, 2015

Hi Jon - that looks interesting - I'll give it a try

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines