zoukankan      html  css  js  c++  java
  • 基础

    结构
    <div class="search">
    <input id="txt" type="text" /><button id="btn">查询</button>
    <label id="message" for="txt">默认的搜索文字</label>
    </div>
    
    
    样式
    
    
    input,
    button {
    border: 0 none;
    padding: 0;
    }
    .search {
    position: relative;
    258px;
    height: 40px;
    margin: 100px auto;
    font-weight:bold;">#666666;
    }
    .search input {
    208px;
    height: 40px;
    font-weight:bold;">#C81623;
    outline-style: none;
    padding-left: 8px;
    }
    .search label {
    position: absolute;
    top: 5px;
    left: 20px;
    font: 400 normal 15px/40px "Microsoft Himalaya";
    color: #d7d764;
    cursor: text;
    }
    .search button {
    42px;
    height: 40px;
    font-weight:bold;">#DDDDDD;
      cursor: pointer;
    }

    行为
    window.onload = function () {
    var oTxt = window.document.getElementById("txt");
    var oMessage = window.document.getElementById("message");
    var oBtn = window.document.getElementById("btn");
    oBtn.onclick = function() {
    window.console.log(oTxt.value);
    }
    oTxt.oninput = oTxt.onpropertychange = function () {
    if (oTxt.value == "") {
    oBtn.style.color = "#000000";
    oMessage.style.display = "block";
    } else {
    oBtn.style.color = "#FF0000";
    oMessage.style.display = "none";
    }
    }
    }
    input标签获得焦点
    window.onload = function () 
    var oTxt = window.document.getElementById("txt");
    oTxt.focus();
    }
    鼠标经过选中内容
    window.onload = function () 
    oTxt.onmouseover = function () {
      oTxt.select();
      }

    }
     
     
     
     
  • 相关阅读:
    课后作业
    动手动脑
    原码,补码,反码
    CodingSouls团队项目冲刺-个人概况(7)
    《人月神话》阅读笔记03
    数据库学习
    家庭小账本——数据库的编写与测试
    家庭小账本——适配器的编写与测试
    UI高级组件
    UI高级组件
  • 原文地址:https://www.cnblogs.com/WeWeZhang/p/5716212.html
Copyright © 2011-2022 走看看