長春語林科技
長春語林科技,您信得過的合作伙伴!
BlogJava
首頁
新隨筆
聯系
聚合
管理
posts - 325, comments - 25, trackbacks - 0
javscript操作Select標簽[動態(tài)添加,清空]
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
>
<
meta
http-equiv
="Content-Type"
content
="text/html; charset=gb2312"
/>
<
title
>
無標題文檔
</
title
>
<
script
type
="text/javascript"
>
function
addList()
{
var
list
=
document.getElementById(
"
list
"
);
for
(
var
i
=
1
; i
<=
5
; i
++
)
{
var
newOption
=
document.createElement(
"
option
"
);
newOption.setAttribute(
"
value
"
, i);
newOption.appendChild(document.createTextNode(
"
測試數據
"
+
i));
list.appendChild(newOption);
}
}
function
clearList()
{
var
list
=
document.getElementById(
"
list
"
);
for
(
var
i
=
list.options.length; i
>=
0
; i
--
)
{
list.remove(i);
}
//
注意:每刪除一個option其它option的index特性會自動重置,因此,按以下方法(即從上往下刪是清除不了的)
//
for(var i = 0; i< list.options.length; i++){
//
list.remove(i);
//
}
}
</
script
>
</
head
>
<
body
>
<
select
name
="list"
id
="list"
>
</
select
>
<
input
type
="button"
onclick
="addList()"
value
="生成"
/>
<
input
type
="button"
onblur
="clearList()"
value
="清空"
/>
</
body
>
</
html
>
posted on 2008-08-26 14:46
長春語林科技
閱讀(275)
評論(0)
編輯
收藏
所屬分類:
js
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發(fā)表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
yarn
node js后臺運行
node-sass
js檢驗寫法 示例
jsonp 調用示例
js 正則總結
js分頁
js 打印
js 文件類型判斷
ip input
Copyright ©2025 長春語林科技 Powered By:
博客園
模板提供:
滬江博客
<
2008年8月
>
日
一
二
三
四
五
六
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
長春語林科技歡迎您!
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(6)
給我留言
查看公開留言
查看私人留言
隨筆分類
ajax(2)
android(5)
css(2)
db2(2)
docker(10)
flex(22)
hibernate(16)
html5(9)
java(12)
java8(8)
jquery(4)
js(30)
jsp(2)
jstl(3)
linux(14)
mongodb(1)
mui(1)
mysql(14)
oracle(3)
spring(8)
sqlserver(4)
struts(9)
struts2(13)
tomcat(6)
UML(1)
util(50)
vue(1)
weblogic(1)
隨筆檔案
2020年4月 (1)
2020年3月 (1)
2020年2月 (2)
2019年10月 (2)
2019年9月 (1)
2019年7月 (1)
2019年4月 (1)
2019年1月 (1)
2018年12月 (2)
2018年8月 (1)
2018年6月 (3)
2018年5月 (9)
2018年3月 (9)
2017年12月 (1)
2017年10月 (1)
2017年7月 (1)
2017年6月 (1)
2017年5月 (1)
2017年3月 (3)
2017年2月 (2)
2017年1月 (1)
2016年12月 (1)
2016年11月 (1)
2016年9月 (1)
2016年4月 (3)
2016年3月 (2)
2015年8月 (5)
2015年3月 (1)
2014年8月 (1)
2012年11月 (1)
2012年5月 (2)
2012年4月 (5)
2011年12月 (1)
2011年10月 (3)
2011年9月 (2)
2011年8月 (10)
2011年7月 (3)
2011年6月 (4)
2011年5月 (2)
2011年4月 (3)
2011年3月 (12)
2011年1月 (2)
2010年12月 (1)
2010年9月 (2)
2010年8月 (4)
2010年6月 (1)
2010年4月 (1)
2010年3月 (1)
2009年11月 (1)
2009年9月 (2)
2009年8月 (1)
2009年7月 (2)
2009年6月 (1)
2009年5月 (3)
2009年4月 (8)
2009年3月 (5)
2009年2月 (4)
2009年1月 (2)
2008年12月 (10)
2008年11月 (2)
2008年9月 (10)
2008年8月 (12)
2008年7月 (12)
2008年6月 (3)
2008年5月 (53)
文章分類
java
util(1)
文章檔案
2017年10月 (1)
相冊
me
收藏夾
store java code
store js code
store other code(2)
搜索
最新評論
1.?re: js 操作文件[未登錄]
00
--00
2.?re: s:bean.jsp
fdfdsa
--dfasdf
3.?re: hibernate 常用標識生成器
藝達廣告歡迎您
--藝達廣告
4.?re: linux mod_jk.so 下載[未登錄]
3Q!
--me
5.?re: weblogic參數設置[未登錄]
垃圾
--xx
閱讀排行榜
1.?關于PreparedStatement插入Date類型值的方法(15470)
2.?myeclipse8.6注冊碼(轉載別人)(9932)
3.?new Date()當前日期格式(7656)
4.?weblogic參數設置(7519)
5.?js 操作文件(7016)
評論排行榜
1.?jstl 下載http://www.apache.org/dist/jakarta/taglibs/standard/binaries/(8)
2.?javamail發(fā)送html郵件(3)
3.?powerdisigner 12 下載(3)
4.?struts2 config(1)
5.?sqlserver備份數據庫表為.txt文本存儲過程 (感謝同事)(1)
主站蜘蛛池模板:
台前县
|
开平市
|
宝应县
|
丹巴县
|
荔波县
|
长宁县
|
扬中市
|
攀枝花市
|
大同市
|
翁源县
|
香格里拉县
|
荔浦县
|
西昌市
|
衡水市
|
辽阳市
|
固阳县
|
桓台县
|
南漳县
|
扬中市
|
凤城市
|
哈密市
|
石棉县
|
高青县
|
桦南县
|
保德县
|
芒康县
|
南陵县
|
温宿县
|
肥西县
|
高尔夫
|
宜城市
|
鄂伦春自治旗
|
宁波市
|
长顺县
|
晋州市
|
瑞昌市
|
白玉县
|
鄂温
|
彰化市
|
青田县
|
漳浦县
|