简体   繁体   English

这个简单的jQuery代码有什么问题?

[英]What is wrong with this simple jQuery code?

What is wrong with this jquery code, the error received on IE is 这个jQuery代码有什么问题,在IE上收到的错误是

Message: Expected ';' 讯息:预期为';'
Line: 10 行:10
Char: 10 字符:10

All I want is to move the mouse over and have an alter pop-up 我只想将鼠标移到上方,并弹出弹出窗口

<script language="javascript" type="text/javascript">
$(document).ready(function() {

    $('#t').bind('onmouseover',function(){
        target: '#t',
        success: function(){
            alert('test');
            }

    });

});
</script>

<div id="t">testing mouse over</div>

Thanks Dave 谢谢戴夫

It's syntactically incorrect. 在语法上是不正确的。 Your call to "bind" should take a function as its second argument, but you've got the syntax of functions and that of object literals jumbled up. 您对“ bind”的调用应将函数作为第二个参数,但是您已经有了函数的语法和对象文字的语法混乱。 I don't know what you want to do so I can't really say how to correct it. 我不知道您想做什么,所以我真的不能说如何纠正它。

Here's how you'd do an alert on mouseover: 以下是您将鼠标悬停时发出警报的方法:

$('#t').bind('mouseover', function(ev) {
  alert('test');
});

Also note that you leave off the "on" in the event name. 另请注意,您在事件名称中省略了“ on”。

$(document).ready(function() {
    $('#t').bind('onmouseover',function(){
            alert('test');
     });
});

The target and success code you put into your code is simply invalid. 您放入代码中的target代码和success代码完全无效。 The second argument for the bind function must take a function as an argument, and what you wrote was attempting to pass it an object literal, and not even succeeding at that. bind函数的第二个参数必须以一个函数作为参数,而您编写的内容试图将其传递给对象常量,甚至没有成功。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM