javascript insertAdjacentHTML
下面的例子使用 INPUT type=checkbox 元素創建了兩個帶有解釋文本的復選框。onclick 事件將調用兩個腳本函數。第一個復選框默認選中。
This example uses the INPUT type=checkbox element to create two check boxes with explanatory text. The onclick events call two script functions. The first check box is checked.
<INPUT TYPE=checkbox CHECKED ID=chk1 onclick="choosebox1()">Uncheck
this check box for some free advice.
<P><INPUT TYPE=checkbox ID=chk2 onclick="choosebox2()">Or check
this check box for a message from our sponsors.
<P ID=SampText>
下面的例子就是用戶單擊復選框時調用的腳本。
This example implements the script when the user clicks either check box.
<SCRIPT>
function choosebox1(){
alert("Never play leapfrog with a unicorn!")
}
function choosebox2(){
SampText.insertAdjacentHTML("AfterBegin","Buy WonderWidgets! ");當點擊復先框時,在復選框后自動增加語句Buy WonderWidgets
}
</SCRIPT>
posted on 2009-11-04 16:04 半導體 閱讀(219) 評論(0) 編輯 收藏 所屬分類: javascript