JS-based implementation HTML PLACEHOLDER attribute prompt text effect example

The instance of this article describes the PLACEHOLDER attributes in HTML based on JS implementation. Share to everyone for reference, specific:

How to implement HTML’s PlaceHolder property effect through JS

We need to do this:

    WWW.JB51.NET JS Realize the PlaceHolder attribute   Function BL () {var A = Document.GtelementByid ("inpt"); if (A.Value.Length    <=0){
          a.style.color="#999999";
          a.value="请输入姓名";
        }
      }
      function fo(){
        var a=document.getElementById("inpt");
        if(a.value=="请输入姓名"){
          a.style.color="black";
          a.value="";
        }
      }
        The operation is as follows:    
Supplement:
Here you add a JQuery implementation of the PlaceHolder property effect example:

基于JS实现html中placeholder属性提示文字效果示例

www.jb51.net jQuery implements the PlaceHolder attribute effect

Function PlaceHolder (Event) {var Self = $ (this), selfdatavalue = self.attr (“Data-Value”), selfValue = self.val (); if (selfdatavalue) { Event.Type== “Click”? (SelfValue == SelfDataValue && (Self.val (“”). CSS (“Color”, “# 333”))): (Event.Type == “blur” && (SelfValue == ” “&& (SelfDataValue) .CSS (” Color “,” # A9A9A9))))))}}}} $ (“# inpt”). on (“Click Blur”, PlaceHolder;
     More about JavaScript related content, readers, interested, can view this site: "JavaScript page element operation skills summary", " JavaScript Operation DOM Skill Summary "  I hope this article will help you JavaScript programming.                      
© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment