文本框内容提示效果

Posted cjxns

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了文本框内容提示效果相关的知识,希望对你有一定的参考价值。

文本内容提示效果,未输入内容时显示文本内容,点击输入时内容后消失,由于是IE8,所以无法利用placeholder实现效果:<input  placeholder="提示语"/>,利用js实现该效果

//给出提示:原因+出行人员
         var tit=document.getElementById("whir$t3371_f7764").value;
         if(tit==""){
             document.getElementById("whir$t3371_f7764").innerText="事由+出行人员";
         }
         var tis=document.getElementById("whir$t3371_f7764");
         tis.onfocus=function(){
        if(this.value==‘事由+出行人员‘){
          this.value=‘‘;
          
        };
      };
       tis.onblur=function(){
        if(!this.value){
          this.value = ‘事由+出行人员‘;
        };
      };

 

<input id="whir$t3371_f7764" value="事由+出行人员">

















以上是关于文本框内容提示效果的主要内容,如果未能解决你的问题,请参考以下文章