zoukankan      html  css  js  c++  java
  • Jquery判断其中任意一个文本框的值是否被修改

    <!doctype html>
    <html lang="en">
     <head>
      <meta charset="UTF-8">
      <meta name="Generator" content="EditPlus®">
      <meta name="Author" content="zzp">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
      <title>Document</title>
      <style type="text/css">   
        input:focus,textarea:focus{
           border:1px solid #f00;
           background:#fcc;
        
        }
        .focus{
           border:1px solid #f00;
            background:#fcc;
        }

       </style>
        <script type="text/javascript" src="js/jquery-1.6.4.min.js" ></script>
        <script type="text/javascript">
           var temp;
         $(function(){
               $(":input").focus(function(){   //获得焦点
                     alert(this.id);  
                     alert("获得焦点时的值是:"+$(this).val());  
                     temp=$.trim($(this).val());
                     alert(temp);
                    $(this).addClass("focus");   //添加样式

               }).blur(function(){ //失去焦点
                   $(this).removeClass("focus"); //移除样式
                   alert("失去焦点时的值是:"+$(this).val());  
                   var lastValue = $.trim($(this).val());  

                   if(temp != lastValue && null !=lastValue && "" !=lastValue)
                   {
                       alert("值改变了!");
                   }
                  
                   else{
                      alert("值没有变!");
                   }
                   /**     */    

               });
        
         });
        
        </script>


     </head>
     <body>
        <form action="#" method="post" id="reFrom">
          <fieldset>
             <legend>个人信息</legend>
             <div>
               <label>名称:</label>
               <input id="username" type="text" value="admin">
             </div>
             <div>
               <label>密码:</label>
               <input id="pass" type="text" value="123456">
             </div>
             <div>
               <label>性别:</label>
               <input id="sex" name="sex" type="radio" value="1" checked="checked">男
               <input id="sex" name="sex" type="radio" value="2">女
             </div>
              <div>
               <label>详细信息:</label>
               <input id="msg" type="text" value="获取值">
             </div>
          
          
          </fieldset>
        
        
        </form>
     </body>
    </html>

  • 相关阅读:
    day01
    ASP.NET 最全的POST提交数据和接收数据 —— (1) 用url传参方式
    Quartz.NET 入门,带C#实例
    asp.net 后台注册(调用)JS
    DataSet和List 泛型之间互相转换 (转载)
    .NET异步编程总结----四种实现模式
    VS2013 “未找到与约束 ContractName Microsoft.Internal.VisualStudio.PlatformUI.ISolutionAttachedCollectionService RequiredTypeIdentity Microsoft.Internal.VisualStudio.PlatformUI.ISolutionAttachedCollectionService 匹配的导出”
    Sql Server 删除所有表、视图、存储过程
    GPS定位,根据经纬度查询附近地点的经纬度-sql方法实现
    GPS定位,经纬度附近地点查询–C#实现方法
  • 原文地址:https://www.cnblogs.com/zengzhanping/p/4353810.html
Copyright © 2011-2022 走看看