Copy class name in javascript -


i need way copy class name 1 object another.

for example

<div id="obj1" class"test"></div> <div id="obj2"></div>  *run code*  <div id="obj1" class"test"></div> <div id="obj2" class"test"></div> 

i'm betting pretty simple question, i'm relatively new javascript.

any appreciated.

var obj1 = document.getelementbyid('obj1'),     obj2 = document.getelementbyid('obj2');  obj2.classname = obj1.classname; 

just make sure code not run before dom ready. simple way place script before </body> tag.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -