zoukankan      html  css  js  c++  java
  • 搜索框js样式(通用型)

    HTML部分代码:

    ——————————————————————————————————————————————————————————————

    <div class="search_box">

            <from>
                    <ul class="search_ul">
                        <li><input  type="text" name="point" value="地点" onblur="returnvalue(this, '地点')" onfocus="Search(this, '地点')" id="obj1"  style="color:#999;"/></li>
                        <li><input  type="text" name="point" value="请输入关键字" onblur="returnvalue(this, '请输入关键字')" onfocus="Search(this, '请输入关键字')" style="color:#999;"/></li>
                        <li class="li_color"><input type="button" name="search" value="搜索" /></li>
                    </ul>
                </from>

    </div>


    js样式:

    ———————————————————————————————————————————————————————————————

    //得到焦点触发事件
    function Search(element,elementvalue)
    {
    if(element.value==elementvalue)
    {
    element.value="";
    element.style.color="#000";
    }
    }
    //离开输入框时触发事件
    function returnvalue(element,elementvalue)
    {
    if(element.value=="" || element.value.replace(/s/g,"")=="")
    {
    element.value=elementvalue;
    element.style.color="#999";
    }
    }

  • 相关阅读:
    [ABC200E] Patisserie ABC 2
    [CF1521E] Nastia and a Beautiful Matrix
    [CF1498D] Bananas in a Microwave
    [CF1515B] Phoenix and Puzzle
    [CF1519C] Berland Regional
    [CF1519B] The Cake Is a Lie
    [ZONe Energy Programming Contest C] MAD TEAM
    [洛谷P7480] Reboot from Blue
    [CF1508A] Binary Literature
    1371. 货币系统
  • 原文地址:https://www.cnblogs.com/lpshan/p/4390764.html
Copyright © 2011-2022 走看看