Jump to content

how make many id in one getElementById


Zerivo
 Share

Recommended Posts

Hi, i make one but it will be many line same, like this with 20.

document.getElementById("Test1").value = Dotoff;
document.getElementById("Test2").value = Dotoff;
document.getElementById("Test3").value = Dotoff;

i wonder can it make all id in one? i tried it:
 

document.getElementById("Test1","Test2","Test3").value = Dotoff;


but it didn't work well, only Test1 change.
some know how make all 20 in one? it can save me lots space/line ;)

Link to comment
Share on other sites

Then too, you could use jQuery, it will do the counting for you.

document.getElementById("Test1").value = Dotoff;
document.getElementById("Test2").value = Dotoff;
document.getElementById("Test3").value = Dotoff;

<element1 class='test'></element1>
<element2 class='test'></element2>
<element3 class='test'></element3>

$('.test').val('Dotoff');

Roddy

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
 Share

×
×
  • Create New...