JS不定长度探究和填充占位符的应用
来源:互联网 发布:lumia2520能用什么软件 编辑:程序博客网 时间:2024/06/06 04:22
<!DOCTYPE html><html><head><script>function myFunction(){alert("Hello World!");}function myFunction(a){alert("Hello World132!");}</script></head><body><button onclick="myFunction(1,1)">点击这里</button></body></html>
JS特点是我们传递了两个参数,没有哪个函数是两个参数的,它应该优先一个参数的
/**填充占位符*/$.format = function (source, params) {if (arguments.length == 1)return function () {var args = $.makeArray(arguments);args.unshift(source);return $.format.apply(this, args);};if (arguments.length > 2 && params.constructor != Array) {params = $.makeArray(arguments).slice(1);}if (params.constructor != Array) {params = [params];}$.each(params, function (i, n) {source = source.replace(new RegExp("\\{" + i + "\\}", "g"), n);});return source;};hdl.messages = {
nan:"第{0}行第{1}列不是一个有效的数字",
具体应用:$.format(hdl.messages.nan,i+1,2)
这里面反映了通过jquery对不定长参数的应用,今后若有需要,可以此作为参考
0 0
- JS不定长度探究和填充占位符的应用
- js占位符的实现
- Java的不定长度参数
- 不定参数的应用
- 不定参数的应用
- 不定参数的应用
- 不定参数的应用
- 不定参数的应用
- 不定参数的应用
- 不定参数的应用
- 不定参数的应用
- 不定参数的应用
- 不定参数的应用
- 不定参数的应用
- 不定参数的应用
- 不定参数的应用
- 不定参数的应用
- 不定参数的应用
- 设计的成长
- java中的断点下载文件
- C++ 将一个文件里面的相同的一个字符串替换成另一个字符串
- Cubietruck开发板SPL阶段的printf重定向问题
- 第五周作业(第四章)
- JS不定长度探究和填充占位符的应用
- 我们还在一起
- hdu3068+hdu3294 最长回文字符串的manacher算法
- IE8下parseInt(8)返回0
- 【Web缓存机制系列】6 – 进击的Hybrid App,量身定做缓存机制
- greenDao
- IOS程序运行时崩溃日志setObjectForKey: object cannot be nil
- IT工程师技能汇总
- MyEclipse搭建struts框架,并且实现登陆流程和拦截器使用(2)