X10nD
X10nD

Reputation: 22030

What is wrong with this simple jQuery code?

What is wrong with this jquery code, the error received on IE is

Message: Expected ';'
Line: 10
Char: 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

Upvotes: -2

Views: 149

Answers (2)

Tyler Carter
Tyler Carter

Reputation: 61557

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

The target and success code you put into your code is simply invalid. 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.

Upvotes: 1

Pointy
Pointy

Reputation: 413702

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. 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.

Upvotes: 2

Related Questions