源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

JavaScript初级教程(第五课续)第1/3页

  • 时间:2022-01-02 06:24 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:JavaScript初级教程(第五课续)第1/3页
    在JavaScript中单选框的用法和复选框相似。不同之处在于HTML中的应用。复选框是一种开关。如果一个复选框被选中,你可以再点击后取消选取. 但如果单选框被选中,则只能通过选取另外一个单选框才能取消对该单选框的选取。例:
    Larry     Moe     Curly
    在该例中,如果你打算取消对一个单选框的选取,你必须点击另一个单选框。再看下面的程序:
    Light off     Light on     表单代码如下:
    <form name="form_1">         <input type="radio" name ="radio_1" onClick="offButton();">Light off         <input type="radio" name ="radio_2" onClick="onButton();" checked>Light on     </form>     当第一个单选框被选中时,函数offButton() 被调用。函数如下:      function offButton()     {         var the_box = window.document.form_1.radio_1;         if (the_box.checked == true)         {             window.document.form_1.radio_2.checked = false;             document.bgColor='black';             alert("Hey! Turn that back on!");         }     }     这个例子很象前面的复选框例子,主要的区别在于该行:      window.document.form_1.radio_2.checked = false;     该行指令指示JavaScript在该按钮被点击时关闭另外一个按钮。由于另外一个按钮的函数同这个很相似:     function onButton()     {         var the_box = window.document.form_1.radio_2;         if (the_box.checked == true)         {             window.document.form_1.radio_1.checked = false;             document.bgColor='white';             alert("Thanks!");         }     } [center][/center]
当前1/3页 [b]1[/b][url=http://www.1sucai.cn/article/9201_2.htm]2[/url][url=http://www.1sucai.cn/article/9201_3.htm]3[/url][url=http://www.1sucai.cn/article/9201_2.htm]下一页[/url][url=http://www.1sucai.cn/article/9201_all.htm]阅读全文[/url]
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部