'effect'在jsfiddle中工作正常,但不在活代码中([object Object]没有方法“效果”) [英] 'effect' works fine in jsfiddle but not in live code ([object Object] has no method 'effect' )

查看:116
本文介绍了'effect'在jsfiddle中工作正常,但不在活代码中([object Object]没有方法“效果”)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

相关,但不是修复: jQuery问题 - #< an Object> ;没有方法



我收到一个错误 Object [object Object]没有方法'effect'当我尝试使用效果在jquery中的函数(doc http ://docs.jquery.com/UI/Effects/Highlight )。它在JSFiddle工作正常,但它的错误,当我运行的网站在Chrome或IE。 div显示,但效果调用抛出一个错误。



在这里可以找到直播版本: http://jsfiddle.net/jcollum / HK625 /



Html

 < a id = showHowThisWorks>这全部如何工作?< / a> 
< div id =howThisWorksstyle =display:none;>
< p>它工作正常< / p>
< / div>

这个coffeescript:

  $(document).ready  - > 
$('#howThisWorks')。hide()

$('#showHowThisWorks')。
$ div = $('#howThisWorks')
$ div.toggle();
$ div.effect(highlight,{},10000)
return

return

在JS中看起来像这样:

  $(document).ready (){
$('#howThisWorks')。hide();
$('#showHowThisWorks')。click(function(){
var $ div;
$ div = $('#howThisWorks');
$ div.toggle();
$ div.effect(highlight,{},6000);
});
});

我试过使$ div在该行而不是使用变量的jquery选择器。我试过在$()中包装$ div。我仍然得到的页面的真实版本的错误。在Chrome和IE9中得到相同的结果。显然,我缺少一些关于jquery对象的行为。

解决方案

我相信jQuery UI未被本地部署:检入Firebug / Chrome等验证。

.toggle()是核心jQuery的一部分, .effect()是jQuery UI的一部分:为了使它不起作用,jQuery UI不能出现。


Related, but not a fix: jQuery issue - #<an Object> has no method

I'm getting an error Object [object Object] has no method 'effect' when I try to use the effect function in jquery (doc http://docs.jquery.com/UI/Effects/Highlight). It's working fine in JSFiddle but it errors out when I run the site in Chrome or IE. The div gets shown but the effect call throws an error.

Live version can be found here: http://jsfiddle.net/jcollum/HK625/

Html

<a id=showHowThisWorks >How does this all work?</a>    
<div id="howThisWorks" style="display: none; ">    
  <p>It works fine</p>
</div>

And this coffeescript:

$(document).ready ->
  $('#howThisWorks').hide()

  $('#showHowThisWorks').click ->
    $div = $('#howThisWorks')
    $div.toggle();
    $div.effect("highlight", {}, 10000)
    return

  return

Which looks like this in JS:

 $(document).ready(function() {
    $('#howThisWorks').hide();
    $('#showHowThisWorks').click(function() {
      var $div;
      $div = $('#howThisWorks');
      $div.toggle();
      $div.effect("highlight", {}, 6000);
    });
  });

I've tried making the $div a jquery selector on that line instead of using the variable. I've tried wrapping $div in $(). I'm still getting the error on the real version of the page. Same result in Chrome and IE9. Clearly I'm missing something about how jquery objects behave.

解决方案

I believe that jQuery UI is not getting deployed locally: check in Firebug/Chrome etc. to verify.

.toggle() is part of core jQuery, .effect() is part of jQuery UI: in order for this not to be working, jQuery UI must not be present.

这篇关于'effect'在jsfiddle中工作正常,但不在活代码中([object Object]没有方法“效果”)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆