JS Some of the tool classes

Source: Internet
Author: User

//写入cookie function setCookie(name, value) {      var Days = 30; //此 cookie 将被保存 30 天      var exp = new Date();      exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);      document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString(); } ///删除cookie function delCookie(name) {      var exp = new Date();      exp.setTime(exp.getTime() - 1);      var cval = getCookie(name);      if (cval != null ) document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString(); } //读取cookie function getCookie(name) {      var arr = document.cookie.match( new RegExp( "(^| )" + name + "=([^;]*)(;|$)" ));      if (arr != null )          return unescape(arr[2]);      return null ; } //===================== cookie相关 end ======================== // //===================== form 表单 序列化 插件 相关 beign ======================== // var $ = jQuery; ( function ($){      $.fn.serializeJson= function (){          var serializeObj={};          var array= this .serializeArray();          var str= this .serialize();          $(array).each( function (){              if (serializeObj[ this .name]){                  if ($.isArray(serializeObj[ this .name])){                      serializeObj[ this .name].push( this .value);                  } else {                      serializeObj[ this .name]=[serializeObj[ this .name], this .value];                  }              } else {                  serializeObj[ this .name]= this .value;              }          });          return serializeObj;      }; })(jQuery); //===================== form 表单 序列化 插件 相关 end ======================== // //===================== 回车触发 子页面 查询事件 相关 beign ======================== // // 主框架页上增加 回车触发frame子页 查询动作 (仅当子页面有 .btnSearch的按钮时才触发) jQuery(window.document).keyup( function (event) {      if (event.which == ‘13‘ ) {          var jBtn = jQuery( ".btnSearch" );          if (jBtn.length > 0) {              jBtn.click();          }      } });

JS Some of the tool classes

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.