function createTable(){ var t=document.createElement('table'); var d=document.getElementById("d1"); var a=d.children; for(var i=0;i<5;i++){ var r=t.insertRow(); r.insertCell().innerHTML = "<textarea name='w10d1t"+a.length+"_a"+(i+1)+"' style='width:100px;overflow:hidden;height:24pt;' theme='simple'></textarea>"; } document.getElementById('d1').appendChild(t); t.setAttribute("id","w10d1t"+(a.length)); t.setAttribute('border','1'); t.setAttribute('class','tableFloat'); }源代码是这样的
var t=document.createElement('table'); 下加一句 t.className='tableFloat';
css:
.tableFloat{ float:left;
display:inline;
width:200px;
} <table class="tableFloat"><tr><td>1111</td></tr></tabel>
<table class="tableFloat"><tr><td>2222</td></tr></tabel>
<table class="tableFloat"><tr><td>333</td></tr></tabel>
css:
.tableFloat{ float:left;
display:inline;
width:200px;
} <table class="tableFloat"><tr><td>1111</td></tr></tabel>
<table class="tableFloat"><tr><td>2222</td></tr></tabel>
<table class="tableFloat"><tr><td>333</td></tr></tabel>这个,是用js添加和删除table,所以不能直接的设置class
css:
.tableFloat{ float:left;
display:inline;
width:200px;
} <table class="tableFloat"><tr><td>1111</td></tr></tabel>
<table class="tableFloat"><tr><td>2222</td></tr></tabel>
<table class="tableFloat"><tr><td>333</td></tr></tabel>这个,是用js添加和删除table,所以不能直接的设置class
?为什么不能添加 class
table对象.className='tableFloat';
css:
.tableFloat{ float:left;
display:inline;
width:200px;
} <table class="tableFloat"><tr><td>1111</td></tr></tabel>
<table class="tableFloat"><tr><td>2222</td></tr></tabel>
<table class="tableFloat"><tr><td>333</td></tr></tabel>这个,是用js添加和删除table,所以不能直接的设置class
?为什么不能添加 class
table对象.className='tableFloat';
function createTable(){
var t=document.createElement('table');
var d=document.getElementById("d1");
var a=d.children;
for(var i=0;i<5;i++){
var r=t.insertRow();
r.insertCell().innerHTML = "<textarea name='w10d1t"+a.length+"_a"+(i+1)+"' style='width:100px;overflow:hidden;height:24pt;' theme='simple'></textarea>";
}
document.getElementById('d1').appendChild(t);
t.setAttribute("id","w10d1t"+(a.length));
t.setAttribute('border','1');
t.setAttribute('class','tableFloat');
}源代码是这样的
下加一句
t.className='tableFloat';
试了试t.style.float="left";也没有用。
是不是跟是用js新创建的有关系啊?