草庐IT

列表函数

全部标签

javascript - 使用 jQuery each() 函数返回一个值

我是javascript的新手,我想从JSON中检索值并将其推送到数组中,以便我可以在另一个函数中再次解析该数组,但我不知道推送后如何返回数组里面的元素。在下面的脚本中我无法显示项目中的值functiongC(b,c,p){$.getJSON('getmonths','b='+b+'&c='+c+'&p='+p,processJSON);}functionprocessJSON(data){varretval=[];$.each(data,function(key,val){retval.push(val);//alert(retval.pop());});returnretval;}

javascript - jquery 的 "live"函数的问题

问题这很好用:$('#edit_curriculum.generated').children().blur(function(){console.log(this);});但这不是:$('#edit_curriculum.generated').children().live('blur',function(){console.log(this);});obs:函数包装在$(document).ready事件中。输出工作:不工作:UncaughtSyntaxerror,unrecognizedexpression:)k.errorjquery.js:17k.filterjquery.

javascript - 包装函数和 function.length

假设我有以下代码/*...*/var_fun=fun;fun=function(){/*...*/_fun.apply(this,arguments);}我刚刚在_fun上丢失了.length数据,因为我试图用一些拦截逻辑来包装它。下面的不行varf=function(a,b){};console.log(f.length);//2f.length=4;console.log(f.length);//2annotatedES5.1specificationstates.length定义如下Object.defineProperty(fun,"length",{value:/*...*/

javascript - Sharepoint 2010 客户端对象模型 - 获取当前列表的名称

我正在尝试为Sharepoint2010中的功能区菜单创建一个简单的自定义操作按钮。我想保持它的通用性,所以不要对库名称等进行硬编码。如何找到当前正在查看的列表的名称?我想这是可能的,而不必从Url中解析它。非常感谢! 最佳答案 这花了一些时间,但我最终找到了答案。您可以使用Javascript获取列表的ID://GettheIdofthelistvarlistId=SP.ListOperation.Selection.getSelectedList(); 关于javascript-Sh

Javascript Prototype Chaining父类(super class)构造函数和方法调用

我是JavaScript世界的新手,在尝试原型(prototype)链继承时遇到了这个奇怪的问题。我有3个类(class)//classparentfunctionparent(param_1){this.param=param_1;this.getObjWithParam=function(val){console.log("valueinparentclass"+val);console.log("Constructorparameter:"+this.param);};};//classchildfunctionchild(param_1){this.constructor(pa

javascript - 在下拉列表更改时替换 URL 查询字符串值

我有一个具有双重作用的下拉菜单。用户可以直接进入页面(http://mysite/events/Pages/default.aspx)并使用下拉菜单,或者他们可以先进行搜索,然后通过选择下拉菜单进一步过滤搜索结果。第一个案例URL就像http://mysite/events/Pages/default.aspx?hos=Carmel和第二个案例网址http://mysite/events/Pages/default.aspx?kwd=health&type=Events&hos=Carmel这就是我现在正在做的,但它表现得很奇怪,并且像这样对urlhttp://mysite.event

javascript - 为什么原型(prototype)函数比默认声明的函数慢 40 倍?

我玩过jsperf.com,发现原型(prototype)函数比“默认”声明的函数慢40倍。String.prototype.contains=function(s){return!!~this.indexOf(s)}=220Kops/s对比functionisContains(str,s){return!!~str.indexOf(s)}=8.5KK操作/秒Here'sajsperftestcase附言我知道原型(prototype)修改不是最好的情况,可以命名为“猴子修补”:) 最佳答案 我认为它很慢,因为字符串基元每次调用一个

javascript - 我可以将 "this"作为参数传递给 javascript 中的另一个函数吗

我有这个:$('#sliderli').click(function(){varstepClicked=$(this).index();alert(stepClicked);if(stepClicked!=0){$('#cs_previous').removeClass('cs_hideMe');}else{$('#cs_previous').addClass('cs_hideMe');}$('li.cs_current').removeClass('cs_current');$($(this)).addClass('cs_current');moveToNextImage(stepC

javascript - 构造函数总是函数对象吗?

我正在阅读最新的ECMA-262引用,2011年6月5.1版。在8.6.2部分关于[[Construct]]内部属性的表9:Createsanobject.Invokedviathenewoperator.TheargumentstotheSpecOparetheargumentspassedtothenewoperator.Objectsthatimplementthisinternalmethodarecalledconstructors.标准并未规定构造函数必须是Function对象。那么我们可以拥有一个不是函数对象的构造函数对象吗?Linktothestandardasrequ

javascript - 在本地存储中保存一个函数

我正在处理一些对象,这些对象包含要从浏览器显示和操作的大量数据,我想将其保存在本地存储中。为了保存对象,我使用了JSON.stringify()所以一切都变成了文本,而且效果很好{"bindingRef":[],"primo":{"name":"primo","modifiable":true,"binded":false,"isInteger":false,"label":"NumerodiPrimi"},"secondo":{"name":"secondo","modifiable":true,"binded":false,"isInteger":false,"label":"Nu