js实用小函数收集

格式化金额

var val=‘212312.235423‘
var rex = /\d{1,3}(?=(\d{3})+$)/g;
val.replace(/^(-?)(\d+)((\.\d+)?)$/, function (s, s1, s2, s3) {
          return ‘$‘ + s1 + s2.replace(rex, ‘$&,‘) + s3;
 })
创建表单,并以post方式提交 $(".details").click(function(){
            var type=$(this).attr("type");
            var financingAmount=$(this).attr("financingAmount");
            var  url = "/supplierAccountCenterController/suppliereceivingadd";
            //首先创建一个form表单
            var tempForm = document.createElement("form");
            tempForm.id="tempForm1";
            tempForm.method="post";
            tempForm.action=url;
            tempForm.target="_blank";
            //创建input标签,用来设置参数
            var hideInput = document.createElement("input");
            hideInput.type="hidden";
            hideInput.name= "type";
            hideInput.value= type; 

            //将input表单放到form表单里
            tempForm.appendChild(hideInput); 

            //将此form表单添加到页面主体body中
            document.body.appendChild(tempForm);
            tempForm.submit();
            document.body.removeChild(tempForm);
}

$.ajaxSetup({cache:false}); 设置ajax非缓存机制

 

判断是否为IE浏览器js代码: (! +[1, ]);

 

原文地址:https://www.cnblogs.com/codechange/p/8367110.html

时间: 2024-07-31 12:54:42

js实用小函数收集的相关文章

JS实用小函数 数据是否合法或存在 获取当前日期时间

1.判断数据是否合法或存在 //判断数据是否合法或存在function isNotNull(data){   if(data === "" || data === undefined || data === null)  //此处用绝对等于,保证数据类型及数据完全一致.根据需要选为"=="    return false;  else     return true;} 2.获取当前的日期时间 格式"yyyy-MM-dd HH:MM:SS" //

node.js实用小模块

1.浮点数操作 npm install float 2.MD5加密类 npm install MD5 3.xml解析类 1 npm install elementtree 4.转换字符串大小写 1 npm install convert_str 5.SoapClient 1 npm install soap 6.字符串操作类 1 npm install string 7.缓存 1 npm install memory-cache 8.jsontoxml;  objecttoxml 1 npm i

Git 实用小命令收集

修改 commit我们经常会在提交的时候拼写错误或者填入一些错误的信息,我们可以使用: git commit --amend 如果你想修改已经提交的过的 commit 信息的话,你需要修改后: git commit --amend // ... edit you messagegit push --force example-branch 合并 commit有的时候我们会经常性的提交,但是等到项目开发差不多得时候在发现 commit 信息很杂乱.你可以使用下面信息将所有的 message 合并在

js函数收集

常见js函数收集: 转自:http://www.qdfuns.com/notes/36030/2eb2d45cccd4e62020b0a6f0586390af.html //运动框架 function animate(obj,targetJson,time,callback){ if(window.navigator.userAgent.indexOf("MSIE") != -1){ var interval = 50; }else{ var interval = 10; } //得到

javascript小技巧-js小技巧收集(转)

本文转载自:http://blog.csdn.net/ocean20/article/details/2498699 每一项都是js中的小技巧,但十分的实用! 1.document.write(""); 输出语句 2.JS中的注释为// 3.传统的HTML文档顺序是:document->html->(head,body) 4.一个浏览器窗口中的DOM顺序是:window->(navigator,screen,history,location,document) 5.得

js 日期计算星座 根据生日的月份和日期,一行代码计算星座的js小函数(转)

本博客根据 开源中国作者清风徐不来 的文章 根据生日的月份和日期,一行代码计算星座的js小函数(转) 原文出自CSDN 无心的专栏 的文章,知识产权归原文作者所有! 点击查看原文:js 日期计算星座

js小函数

前言 对于项目中常用的一些函数总结. note 阻止F5刷新 $(document).keydown(function(e){ var ev = window.event || e; var code = ev.keyCode || ev.which; if (e.keyCode == 116){ ev.keyCode ? ev.keyCode = 0 : ev.which = 0; cancelBubble = true; return false; } }) Enter键登录 $(docum

几个非常有用的js小函数

1 function $(v){ 2 if(typeof v==="function"){ 3 window.onload=v; 4 }else if(typeof v==="string") 5 { 6 return document.getElementById(v); 7 }else if(v==="object") 8 { 9 return v; 10 } 11 } 12 这个小函数模拟jQuery中的$函数做了一些非常简单的事情.用来获

JS_ECMA基本语法中的几种封装的小函数-2

大家好!今天继续给大家写一下ECMA中的剩下的小函数以及实用的实例: 首先先给大家说一下字符串.数组.数学方法以及json的一点小知识点: 字符串方法: str.length str.charAt(i):取字符串中的某一个; str.indexOf('e');找第一个出现的位置;找不到返回-1; str.lastIndexOf('e'):找最后一个e出现的位置;找不到返回-1; str.toUpperCase();转大写 str.toLowerCase();转小写 str.substring(起