bind - mouse over ul list

时间:2011-09-15 16:15:33

标签: jquery bind html-lists

我遇到这种情况:

<ul id="country_list"onmouseover="cl();">

function cl(){ 
// something to do 
}

此功能可用,但不是声音。

所以我这样做:

$('#country_list').bind('mouseover', function () { // do what you want to do on mouse over });

但功能不起作用!!!

对于解决方案,我已经看到了这个问题My mouseover, mouseleave doesnt work,我已经尝试了所有的建议,但没有!

为什么???

在名为variables and jquery: how capture value and use them (part 3)的问题中,您可以找到function cl()的所有代码。

感谢

1 个答案:

答案 0 :(得分:1)

您使用mouseover()是否有任何特定原因?我建议hover()

$('#country_list').hover(function () {
    // Do something
    alert('Im doing something!');
});

更多:

$('#country_list').hover(function () {
    // Do something on mouseover
    alert('Cursor landed on the object');
}, function () {
    // Do something on mouseout
    alert('Cursor left the object');
});

附注:如果这不起作用,则很可能问题出在其他地方。也许你忘了一般包含jQuery,或者某处有一个基本的JS问题。