∥″可乐〃∥

让我展望未来,网络是我不变的终结者!

« 请勿酒后驾驶广告创意国内几个比较牛的前端博客推荐 »

点击文本框文字消失

第一种:
<html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    </head> 
    <body>
 
        <input type="text" value="请输入..." id="phpzixue" /> 
 <script language="JavaScript" type="text/javascript"> 
            function addListener(element,e,fn){ 
             if(element.addEventListener){ 
             element.addEventListener(e,fn,false); 
             } else { 
              element.attachEvent("on" + e,fn); 
              } 
            } 
            var phpzixue = document.getElementById("phpzixue"); 
            addListener(phpzixue,"click",function(){ 
                phpzixue.value = ""; 
            }) 
           //addListener(phpzixue,"blur",function(){  //失去焦点时的动作
           //     phpzixue.value = "请输入..."; 
           // }) 

 </script>
    </body> 
</html> 

第二种:

<input type="text" value="单击则选中!" onclick="this.select()">

onclick事件调用select()方法,选中自身
用onfocus="this.select()"也可,onfocus就是指自身被聚焦,这个跟onclick效果是一样的

 

Comments.

◎ welcome to participate in the discussion

日历

Comments.

Previous.

ADMIN. | EMAIL. | ABOUT.

Powered By Z-Blog 1.8 Spirit Build 80722Copyright © 2006-2011 可乐Blog Kele520.Com All Rights Reserved.[皖ICP备 06001314号]