两个小的表单方法

来源:互联网 发布:电脑用户名及域名 编辑:程序博客网 时间:2024/05/20 22:38

这里介绍两个属于表单的方法:

  1. 表单自动获得焦点—XX.focus();
  2. 鼠标经过表单时,自动选择表单内容—XX.select();

    <script type="text/javascript">    window.onload = function () {        var txt = document.getElementById("txt");        var sel = document.getElementById("sel");        //表单自动获得焦点        txt.focus();        //鼠标经过表单自动选择表单内容        sel.onmouseover = function () {            sel.select();        }    }</script>
原创粉丝点击