草庐IT

undefined-index

全部标签

javascript - 有没有办法在不迭代的情况下将匹配元素的 z-index 增加 1?

我必须将所有span类.page的z-index增加1。可以有超过100个匹配元素(在任何情况下都不能超过150)。现在我正在遍历它们中的每一个并通过以下代码更改z-index。$('#mydivspan.page').each(function(){varzi=parseInt($(this).css('z-index'))+1;$(this).css('z-index',zi);});有没有更好的方法来处理它以获得更好的性能。我正在使用jQuery。 最佳答案 一些棘手的方法是,创建新样式varstyle=document.cr

javascript - 我有错误 document.registerElement undefined

JavaScript运行时错误:对象不支持属性或方法“registerElement”在文件中:...bower_components\polymer\polymer.js11701行document.registerElement('polymer-element',{prototype:prototype});我的凉亭:{"name":"Polymer","version":"0.0.0","main":"main","license":"MIT","private":true,"dependencies":{"polymer":"Polymer/polymer#~0.5.2","

javascript - 我如何在同一目录中需要来自 index.js 的内容?

我有以下文件结构:models/index.jssomething.jsuser.js在index.js中(这是由Sequalize生成的,从这里导入的东西在其他目录中有效):'usestrict';varfs=require('fs');varpath=require('path');varSequelize=require('sequelize');varbasename=path.basename(module.filename);varenv=process.env.NODE_ENV||'development';varconfig=require(__dirname+'/..

javascript - 类型错误 : 'undefined' is not a function (evaluating '$( "#wnd_Addparam"). 对话框')

我有2个月的这个例子,我换了PC。现在这似乎不再起作用了。这是一个应该通过(之前)按下按钮来加载小窗口对话框的示例。但是,它不起作用...这是我的代码://varregex,v,l,c,b;$("#wnd_Addparam").dialog({autoOpen:false,height:'auto',width:350,modal:true,resizable:false,buttons:{"Add":function(){$(this).dialog("close");},Cancel:function(){$(this).dialog("close");}},close:funct

javascript - 绑定(bind)到 `undefined` 而不是 `null` 有什么好处

我经常看到,当需要在没有特定上下文的情况下使用绑定(bind)参数调用函数时,undefined通常比null更受欢迎上下文,如:f.call(undefined,param1,param2)优于:f.call(null,param1,param2)我想知道这是否有任何特殊原因? 最佳答案 What'sthebenefitofbindingtoundefinedinsteadofnull?我认为没有。来自10.4.3EnteringFunctionCode:Ifthefunctioncodeisstrictcode,settheTh

javascript - AngularJS $cookies.get() 总是返回 undefined

我正在使用AngularJS1.4.0和$cookies服务。以下代码将始终打印出一个空对象:(function(){varapp=angular.module("user-cookies-service",[]);app.service('UserCookiesService',["$cookies",function($cookies){$cookies.put("Hello","World");console.log($cookies.getAll());}]);})();我试过:使用AngulerJS1.3.15和$cookieStore,当浏览器刷新时cookie不会持续存在

javascript - 错误 : Invalid value for <g> attribute transform ="translate(undefined,undefined)"

我在集群中遇到d3.js问题。它给了我以下错误:Error:Invalidvalueforattributetransform="translate(undefined,undefined)"我不知道为什么它会给我。代码:varloadd3=function(){functionelbow(d,i){return"M"+(d.source.y+100)+","+d.source.x+"V"+d.target.x+"H"+(d.target.y+100);}varwidth=(window.innerWidth-100),height=(window.innerHeight-20);va

javascript - nodemon 找不到模块 '/path/to/project/home/index.js'

我在Linux机器上使用nodmeon1.9.1版。我正在运行nodemon:nodemon--watch./build我在构建文件夹中有我的index.js内容。但是当我运行nodemon时,它一直在项目的主文件夹中寻找index.js文件,因此它抛出一个错误,因为它在那里找不到它。我尝试检查nodemon--help以获得更好的选项,但我没有看到任何选项,并且还在脚本对象的package.json文件中写入了它,它仍然会抛出相同的错误。我也尝试运行它,因为nodemon--watch./build/index.js仍然抛出错误。此外,index.js文件只包含一个console.l

javascript - 为什么分配给 `NaN` 或 `undefined` 会导致 TypeError?

A.S.:问题是关于错误的类型,而不是关于现象"usestrict"如果NaN和undefined等系统变量发生更改,则会抛出TypeError。但为什么是类型错误呢?为什么不是语法错误?编辑:实际上,这里不是SyntaxError,因为代码段的语法没有错误。但错误的根源在于,某些protected对象无法手动更改;所以,很可能是访问错误(我知道没有这样的错误)。那么,为什么访问错误看起来像类型错误? 最佳答案 在ES5中,有6种不同的nativeerrors:EvalErrorThisexceptionisnotcurrently

javascript - 包裹在 setTimeout 中时出现错误 "Cannot read property of undefined"

这个问题在这里已经有了答案:Passcorrect"this"contexttosetTimeoutcallback?(6个答案)关闭6年前。我一直在编写一段代码,旨在处理单个网页上的多个小视频元素,但我无法使多个进度条与其各自的视频同步。(CurrentjsFiddleprototype)这段代码$(this).find("progress").attr("value",$("video",this)[0].currentTime);似乎有效在主函数中,但是当我用setTimeout将它包装在另一个函数中时,进度条实际上是动画的,我得到了这个错误:"Cannotreadpropert