html中實現(xiàn)文本框出現(xiàn)提示功能的多種方法

字號:


    可以用html5中的屬性 < input ="text" placeholder="你想輸入的內(nèi)容" >
    也可以用js做到 加css樣式
    代碼如下:
    <style type="text/css">
    .in_search {
    border:1 none;
    color:#999999;
    float:left;
    font-size:14px;
    height:18px;
    line-height:18px;
    margin:3px 2px;
    width:253px;
    }
    </style>
    <input name="q" onfocus="if(this.value=='請輸入你想要輸入的內(nèi)容'){this.value='';}" onblur="if(this.value==''){this.value='請輸入你想要輸入的內(nèi)容';}" type="text" value="請輸入你想要輸入的內(nèi)容"/>