0
例(在Firefox)工作: http://progamonth.com/files/tablestestfile.htmljQuery的 - 动态表行不会在IE /歌剧
我不能选择动态获取添加到表元素。这在Firefox中有效,但在IE和Opera中失败。这里发生了什么?
DOM代码:
<table id = "myTable">
<thead>
<tr><th>1</th><th>2</th><th>3</th>
</thead>
<tbody>
</tbody>
</table>
<select id = "select1" class = "hidden">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<select id = "select2" class = "hidden">
<option>A</option>
<option>B</option>
<option>C</option>
</select>
Javascript:
$(document).ready(function(){
$('#myTable tbody').append(generate());
});
function generate()
{
var $row = $('<tr>');
var selects = [$('#select1'),
null,
$('#select2')];
for(var i in selects)
{
var $td = $('<td></td>');
if(selects[i] != null)
{
var $select = selects[i].clone().show().removeAttr("id");
$select.find('option:first').before($('<option>'));
$select.val("");
$td.append($select);
}
$row.append($td);
}
return $row;
}
你想什么目标用这个来完成? – Patrick 2010-07-27 05:06:37