要实现光标定位在文本框显示提示消息用JS怎么实现。急急急急急

解决方案 »

  1.   

    <html>
    <body>
    <input type=text id=tt>
    <input type=button onclick="kk()" name="button">
    <script>
    function kk(){
    var tt= document.getElementById("tt");
    tt.focus();}
    </script>
    </body>
    </html>
      

  2.   

    <html>
    <head>
    <title>test</title>
    <script>
    function clickTextInput(){
    var msgDiv = document.getElementById("msg");
    msgDiv.innerText="you click the text input.";
    }
    </script>
    </head>
    <body>
    <form>
    <table>
    <tr>
    <td><input name="yourname" type="text" onclick="clickTextInput();" />
    </tr>
    </table>
    <div id="msg" ></div>
    </form>
    </body>
    </html>
      

  3.   

    <input title="prompt ?">
      

  4.   

    http://zjhh.blogchina.com/3158296.html
    这里下载个例子看看,应可以实现你说的样子.
      

  5.   

    写的很好,不过onclick改成onfocus更完美。
    <html>
    <head>
    <title>test</title>
    <script>
    function clickTextInput(){
    var msgDiv = document.getElementById("msg");
    msgDiv.innerText="you click the text input.";
    }
    </script>
    </head>
    <body>
    <form>
    <table>
    <tr>
    <td><input name="yourname" type="text" onfocus="clickTextInput();" />
    </tr>
    </table>
    <div id="msg" ></div>
    </form>
    </body>
    </html>
      

  6.   

    谢谢各位不过,我要实现的是类似与图片alt属性样的效果
      

  7.   

    <html>
    <head>
    <title>test</title>
    <script>
    function clickTextInput(){
    var msgDiv = document.getElementById("msg");
    msgDiv.innerText="you click the text input.";
    }

    function mouseOverTextInput(){
    var msgDiv = document.getElementById("msg");
    msgDiv.innerText="your mousr over.";
    }

    //页面内元素的onmouseover事件的处理方法
    document.onmousemove=function(){
    if(event.srcElement.hint) {
    a.style.display="block";
    a.innerHTML=event.srcElement.hint;
    a.style.left=window.event.clientX+10;
    a.style.top=window.event.clientY+10;
    setTimeout("a.style.display='none'",8000);
    }else{
    a.style.display="none"
    }
    }
    </script>
    </head>
    <body>
    <form>
    <table>
    <tr>
    <td><input name="yourname" hint="这是一个输入框" type="text" onclick="clickTextInput();" onmouseover="javascript:mouseOverTextInput();" />
    </tr>
    </table>
    <div id="msg" ></div><div id="a" style="position:absolute;font-size:9pt;display:none;border:1px solid black;background:lightyellow"> </div>
    </form>
    </body>
    </html>