JBOSS 点滴

丰丰的博客

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 半导体 阅读(201) 评论(0)  编辑  收藏 所属分类: javascript


只有注册用户登录后才能发表评论。


网站导航: