草庐IT

T_OLD_FUNCTION

全部标签

jquery - 类型错误 : 'undefined' is not a function (evaluating '$(document)' )

我正在使用WordPress网站。我将此脚本包含在header中。当脚本加载时,我得到这个错误:TypeError:'undefined'isnotafunction(evaluating'$(document)')我不知道是什么原因造成的,甚至不知道它意味着什么。在Firebug中,我得到这个:$isnotafunction 最佳答案 WordPress在noConflict中使用jQuery默认模式。您需要使用jQuery作为变量名来引用它,而不是$,例如使用jQuery(document);代替$(document);您可以轻

jquery - 如何添加显示:inline-block in a jQuery show() function?

我有这样的代码:functionswitch_tabs(obj){$('.tab-content').hide();$('.tabsa').removeClass("selected");varid=obj.attr("rel");$('#'+id).show();obj.addClass("selected");}show函数添加了display:block。但我想添加display:inline-block而不是block。 最佳答案 尝试使用CSS来隐藏和显示内容,而不是show。functionswitch_tabs(obj

javascript - 打开新的基础元素时出现 "Uncaught TypeError: a.indexOf is not a function"错误

我通过bash创建了一个新的Foundation5元素,foundationnewmy-project。当我在Chrome中打开index.html文件时,控制台中显示了一个UncaughtTypeError:a.indexOfisnotafunction错误,源自jquery.min.js:4.我按照基金会网站上的步骤创建了元素,但我似乎无法摆脱这个错误。Foundation和jQuery看起来它们包含在index.html文件中并正确链接,链接的app.js文件包含$(document).foundation();有谁知道是什么导致了这个错误?什么是解决方案?

javascript - Function.prototype.call.bind 是如何工作的?

我在思考这个函数时遇到了一些麻烦:vartoStr=Function.prototype.call.bind(Object.prototype.toString);toStr([])//[objectArray]​​​​​​​​​​​​​​​​​​​​​​​​​​​如第2行所示,此函数如何接受参数? 最佳答案 嗯,Function.prototype.call引用“call”函数,该函数用于调用具有选定的this值的函数;随后的.bind引用Function原型(prototype)上的“bind”函数(记住:“call”也是一个函

javascript - 禁用 JSHint 警告 : Expected an assignment or function call and instead saw an expression

这个问题在这里已经有了答案:Expectedanassignmentorfunctioncallandinsteadsawanexpression(4个答案)Whydoesjshintnotrecognizeanassignmentasanexpression?(8个答案)关闭7年前。我有以下行:imageUrl&&(data.imageUrl=imageUrl);对于这一行,JSHint提示:Expectedanassignmentorfunctioncallandinsteadsawanexpression.我理解警告,但我想禁用它。我找不到怎么做的方法。有什么想法吗?

javascript - 使用 $(function 等启动 javascript 代码

我正在研究来自http://todomvc.com/的Backbone和todo示例应用程序我注意到有3种启动文件中代码的方法:$(function(){//codehere});$(function($){//codehere});(function(){//codehere}());我不明白其中的区别以及何时应该使用其中一个。我还看到一些人用它来开始他们的代码:$(document).ready(function(){//codehere});据我所见,这是完整的写法吧?以更一般的方式,我是否应该始终将我的javascript代码包含在每个文件中的类似内容中?感谢您的建议。

javascript - .substring 错误 : "is not a function"

我不明白为什么我使用substring方法声明变量时会收到错误消息。我想在比较中使用URL的第一部分。网站:http://www.elizabet.nl/wordpress这是出错的部分:varcurrentLocation=document.location,muzLoc=currentLocation.substring(0,45),prodLoc=currentLocation.substring(0,48),techLoc=currentLocation.substring(0,47);错误:“currentLocation.substring不是函数”但这部分代码没问题:va

javascript - 无法加载资源 : the server responded with a status of 500 (Internal Server Error) in Bind function

关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。这个问题似乎与helpcenter中定义的范围内的编程无关。.关闭9年前。Improvethisquestion我正在尝试使用Ajax发送调用,但在Chrome中出现错误,但在Firefox中没有错误。但它仍然无法调用该方法。我试图在Firebug中记录我的调用,但在Firebug中没有调用请求。这就是Firefox没有错误的原因。Index.chshtml代码如下functiononLoad(e){vargrid=$(this).data("tGrid");//bindtothecontextmen

javascript - 为什么 Function.prototype.bind 很慢?

比较thisbenchmark时使用chrome16与opera11.6我们发现在chrome中,原生绑定(bind)比模拟版本的绑定(bind)慢近5倍在Opera中,原生绑定(bind)比模拟版本的绑定(bind)快将近4倍在这种情况下绑定(bind)的模拟版本是varemulatebind=function(f,context){returnfunction(){f.apply(context,arguments);};};存在这种差异是否有充分的理由,或者这只是v8优化不够的问题?注意:emulatebind只实现了一个子集,但这并不真正相关。如果你有一个全功能和优化的模拟绑定

javascript - react 路由器 : run is not a function

Egghead教程是这样教的:varReact=require('react');varRouter=require('react-router');varroutes=require('./config/routes');Router.run(routes,function(Root){React.render(,document.getElementById('app'));});但是我得到这个错误:UncaughtTypeError:Router.runisnotafunction注意:我已经将react-router更新到最新版本。 最佳答案