草庐IT

Read-Only

全部标签

javascript - jQuery 插件返回 "Cannot read property of undefined"

我正在尝试做我做过很多次的事情。我不明白为什么这不起作用。无论我如何编写jQuery代码,它都不起作用。menuitems[i].action()只是不工作。下面是示例1,在这个示例中,无论单击什么项目,它都会返回最后一个项目的操作(在本示例中为alert('Forward!'))。第二个返回未定义的属性。完整错误如下。我的jQuery插件是这样调用的(以下示例是同一调用发生的情况):$('p').contextMenu([{name:'Back',action:function(){alert('Back!');},icon:'http://cdn.iconfinder.net/da

Javascript 未捕获类型错误 : Cannot read property '0' of undefined

我知道有很多与此错误相关的问题,我已经检查了其中的大部分,但没有一个能帮助我解决我的问题。(这看起来很容易调试...)我有一个数组(一开始是空的):varwords=[];我的函数hasLetter,检查我们是否在数组(我在这里称之为:d)单词中找到一个字母(对象)。functionhasLetter(letter,d){//ifwords[0]notnullshouldreturnobjectofletter"a",herewegetting//theindexoftheletter(sinceasciiof"a"is97,Isubstract97)varascii=letter.c

javascript - 未捕获的类型错误 : Cannot read property 'name' of undefined

我尝试使用facebookapi将数据提取到表单输入中。现在,一切都很顺利,直到我还尝试获取当前用户的位置。如果当前用户分享了他的位置(他住在哪里),那么我就没有问题。但是,如果用户没有在Facebook上分享他的位置,我会收到一个错误:未捕获的类型错误:无法读取未定义的属性“名称”这是我一直在使用的代码。如果您有解决方法,请在此处发表评论:)//AdditionalJSfunctionsherewindow.fbAsyncInit=function(){FB.init({appId:'*******',//AppIDstatus:true,//checkloginstatuscook

javascript - d3-drag 0.3.0 - "Cannot read property ' button' of null"

我正在尝试将d3-drag与Canvas一起使用:select(canvas).call(drag().container(canvas).subject(partial(getNodeAtMouse,simulation,canvas)).on('start',someFunction))但是,当我实际尝试拖动时出现以下错误:Cannotreadproperty'button'ofnull从d3-drag(d3原始源代码)中的以下行functiondefaultFilter(){return!d3Selection.event.button;}如果我删除该函数(通过指定我自己的过滤器

javascript - "Cannot read property ' xxx ' of null"

我有一个包含子项的文档片段,我想循环(如果可能)。这会导致错误“无法读取null的属性‘xxx’”。我如何测试是否会出现这种情况? 最佳答案 您可能需要执行以下操作:if((documentFragment!==null)&&documentFragment.hasOwnProperty('xxx')){//handlepropertyxxxofdocumentFragmentasrequired} 关于javascript-"Cannotreadproperty'xxx'ofnull"

javascript - 未捕获的类型错误 : Cannot read property 'appendChild' of null

这个问题在这里已经有了答案:WhydoesjQueryoraDOMmethodsuchasgetElementByIdnotfindtheelement?(6个答案)关闭7个月前。我收到以下错误UncaughtTypeError:Cannotreadproperty'appendChild'ofnullmyRequest.onreadystatechange@script.js:20用我下面的代码//index.htmlSimplePageThisisanAJAXExample这是我的JavaScript文件//script.js//1.CreatetherequestvarmyReq

javascript - jQuery 验证与 Summernote 编辑器错误 : Cannot read property 'replace' of undefined

我正在使用MVC5通过summernote编辑器构建一个表单。Razor代码:@Html.LabelFor(model=>model.Content,htmlAttributes:new{@class="control-label"})@Html.EditorFor(model=>model.Content,new{htmlAttributes=new{@class="form-controlpost-content"}})@Html.ValidationMessageFor(model=>model.Content,"",new{@class="text-danger"})JS:$(

javascript - Angular 4 : Build to prod: Property is private and only accessible within class

我正在使用Angular4,我正在运行:ngbuild--prod我明白了:ngbuild--prodYourglobalAngularCLIversion(1.2.2)isgreaterthanyourlocalversion(1.0.0).ThelocalAngularCLIversionisused.Todisablethiswarninguse"ngset--globalwarnings.versionMismatch=false".Hash:7fce5d10c4c3ac9745e8Time:68351mschunk{0}polyfills.7790a64cc25c48ae62

javascript - jquery.off() : how to remove a certain click handler only?

我有一个绑定(bind)了两个处理程序的元素:pushme$('.pippo').on('click',function(){alert("pippo");});$('.pluto').on('click',function(){alert("pluto");});我正在尝试.off()只有其中一个,但我无法理解语法:-(我正在尝试......remove$('.dai').on('click',function(){$('.pippo').off('click');alert("ok,removed");});但这会删除两个处理程序。所以我正在尝试...$('.pippo').off

javascript - Jquery 验证 : allow only alphabets and spaces

我的验证只接受字母。我也想要允许空格。$.validator.addMethod("alpha",function(value,element){returnthis.optional(element)||value==value.match(/^[a-zA-Z]+$/);});这里需要做什么改变? 最佳答案 代替下面的正则表达式:/^[a-zA-Z]+$/使用这个:/^[a-zA-Z\s]+$/这也会占用空间。 关于javascript-Jquery验证:allowonlyalphab