Same element in different layouts


(Jose) #1

Hello,

I wanted to use the same element in different layouts. First I’ve been using “getElementById” and everything worked fine but in the other layouts. After that I realized the same id can´t be used twice so I tried changing “getElementByI” in my javascript for “getElementsByClassName” but it is not working. What am I doing wrong?

Thanks.


#2

getting Elements by class name returns an array. Example:

var classNames = document.getElementsByClassName("myName");

var firstElement = classNames[0];
var secondElement = classNames[1];

etc…

It’s difficult to give you an exact answer without seeing what you’ve done.

D


(Jose) #3

What I’m doing is an audio player with: a button that changes when it plays, a draggable area to go forward or backward in the progress of the audio and a time counter. I use the functions in elementbyid, but when I change the layout it is not working. I’m not sure about how to do it with classname.

Thanks.