【问题标题】:HoverIntent jQuery and calling the jQuery scriptHoverIntent jQuery 和调用 jQuery 脚本
【发布时间】:2012-08-21 20:02:51
【问题描述】:

我正在努力将 hoverintent jQuery 集成到我的网站中。我已将它插入我的代码,但我从 Chrome 调试器收到错误消息。错误为Uncaught TypeError: Cannot use in operator to search for display in undefined。我不确定出了什么问题。这是我的代码。

<script src="http://code.jquery.com/jquery-latest.js"></script>

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js">  

<script type="text/javascript" src="http://cherne.net/brian/resources

/jquery.hoverIntent.js"></script>

</script> 

<script type="text/javascript" >

$(document).ready(function() {

var config = {    

  sensitivity: 3,
  interval: 200,   
  over: $(this).animate({opacity: 1}, 500), 
  timeout: 500, 
  out: $(this).animate({opacity: 0}, 500) 

};

var config_1 = {    

  sensitivity: 3, 
  interval: 200,    
  over: $(this).animate({opacity: 1}, 500),
  timeout: 500,    
  out: $(this).animate({opacity: 0}, 500) 

};


$('#form1').hoverIntent(config);

$('#form2').hoverIntent(config_1);

});

</script>

这里是html代码

<div id="div1">

<form action="" id="form1" method="post">

<textarea id="inputbox1"  name="what_i_do" maxlength="160" value=""><?php echo   

$profile_data['what_i_do']; ?></textarea>

<input type="submit" id="button1" value="Edit">

</form>

</div>

<div id="div2">

<form action="" id="form2" method="post">

<textarea id="inputbox2" name="fait_accompli"  maxlength="160" value=""><?php echo 

$profile_data['fait_accompli']; ?></textarea>

<input type="submit" id="button2" value="Edit">

</form>

</div>

【问题讨论】:

    标签: jquery hoverintent


    【解决方案1】:

    这是因为您缺少 document.ready 函数的右大括号和括号

    $('#form1').hoverIntent(config);
    
    $('#form2').hoverIntent(config_1);
    }); // <-----  here to close the document.ready function
    

    更改您的配置以包含 function()

    var config = {       
      sensitivity: 3,
      interval: 200,   
      over: function(){
             $(this).animate({opacity: 1}, 500)
      }, 
      timeout: 500, 
      out: function(){
             $(this).animate({opacity: 0}, 500)
      }    
    };
    

    另外,如果两个配置相同,您可以删除其中一个

    【讨论】:

    • 嗯,现在我收到了Uncaught TypeError: Cannot use 'in' operator to search for 'display' in undefined
    • 使用脚本导入进行了切换,但仍然收到 Uncaught TypeError。
    • @jason328 是的,我猜 hoverintent 不依赖于 jQuerUI.. 我只是假设它是.. 它是否显示错误发生在哪个行/文件中?
    • 在 jquery-latest.js:6353 行
    • 把它放在那里。如果您还需要什么,请告诉我。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-12
    • 1970-01-01
    • 1970-01-01
    • 2012-04-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多