我想使用javascipt Dom编写这个html代码(包含许多div并且每个div有不同的类)
<div class="row">
<div class="col s12 m6">
<div class="card blue-grey darken-1">
<div class="card-content white-text">
<span class="card-title">Card Title</span>
<p>I am a very simple card. I am good at containing small effectively.</p>
</div>
</div>
</div>
</div>
检查我的尝试,但它不起作用
var row1 = document.querySelector('row');
var div1 = document.createElement('div');
div1.className('col s12 m6');
var div2 = document.createElement('div');
div2.className('card blue-grey darken-1');
var div3 = document.createElement('div');
div3.className('card-content white-text');
var span1 = document.createElement('span');
span1.className('card-title');
var para = document.createElement('p');
var paracontent = document.createTextNode('this is new world');
para.appendChild(paracontent);
div3.appendChild(para);
div2.appendChild(div3);
div1.appendChild(div1);
row1.appendChild(div1);
慕神8447489
Helenr
相关分类