<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script>
//dosomething
},0)
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
window.onload = (function(){
$("button").click(function(){
$("<option value="+($("#sel1 option").length+1)+">"+($("#sel1 option").length+1)+"</option>").appendTo($("#sel1"));
});
});
</script></head>
<body>
<select id=sel1 onchange="tbl1.className=('c'+this.value);">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
</select>
<button>add</button>
</body>
</html>
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
window.onload = (function(){
$("button").click(function(){
$("<option value="+($("#sel1 option").length+1)+">"+($("#sel1 option").length+1)+"</option>").appendTo($("#sel1"));
alert($("#sel1 option:last").text());
$("#sel1 option:last").text("test");
alert($("#sel1 option:last").text());
});
});
</script></head>
<body>
<select id=sel1 onchange="tbl1.className=('c'+this.value);">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
</select>
<button>add</button>
</body>
</html>
我用 setTimeout (XX, 0) 也不行
得延时300以上才行
请问有啥可靠的方法没??谢谢
$("<option>")
.attr("value", '值1')
.text("选项1")
.appendTo("#sel1");
});立刻生效,不论任何浏览器
$(" <option>")
.attr("value", '值1')
.text("选项1")
.appendTo("#sel1");
});立刻生效,不论任何浏览器