js简单鼠标触发事件

 <title></title>
    <style type="text/css">
        input
        {
            color:#808080;
        }
    </style>
    <script type="text/javascript">
        function gel(id) { return document.getElementById(id); }
        window.onload = function () {
            var input = document.getElementsByTagName("input");
            for (var i = 0; i < input.length; i++) {
                input[i].onfocus = function () {
                    for (var j = 0; j < input.length; j++) {
                        input[j].style.backgroundColor = "#fff";
                        input[j].value="请输入正确的内容"
                    }
                    this.value = "";
                    this.style.backgroundColor = "yellow";
                }
            }
        }
    </script>
</head>
<body>
    <table>
        <tr>
            <td id="td1"><input type="text" value="请输入正确的内容"/></td>
            <td id="td1"><input type="text" value="请输入正确的内容"/></td>
            <td id="td1"><input type="text" value="请输入正确的内容"/></td>
        </tr>
    </table>
</body>

posted @ 2013-01-22 22:27  逊老头  阅读(290)  评论(0编辑  收藏  举报