2017-04-25 5 views

答えて

3

は、classNameプロパティはclassの代わりに使用されている:

function connectedCallback() { 
 
    var on_off_switch = document.createElement('div') 
 
    on_off_switch.className = 'switch demo3' 
 

 
    this.appendChild(on_off_switch) 
 
}

0

class素子属性の名前であり、classNameその対応である:

on_off_switch.className = 'switch demo3' 
// or  
on_off_switch.setAttribute('class', 'switch demo3') 
関連する問題