我有我的这些形式的按钮,我想结合“的mouseenter”和“鼠标离开”事件,他们这是我写Jquery-。每()不工作
$("button").each(function() {
$(this).bind("mouseenter", function() { $(this).css("border", "1px gray outset") });
$(this).bind("mouseleave", function() { $(this).css("border", "none") });
});
这个代码代码只能在第一个按钮上工作,其余的事情都不会发生。 这是我的全码:
$("button").each(function() {
$(this).hover(function() { $(this).css("border", "1px gray outset") }, function() { $(this).css("border", "none") });
$(this).bind("mousedown",$(this).css("border", "inset"));
$(this).click(DoSubmit($(this), 'CLICK', ''));
});
没有什么错,你发布的代码(http://jsfiddle.net/xJ6Ff/)。尝试在http://jsfiddle.net上设置演示,以显示您遇到的问题。 – Matt 2012-03-14 10:29:55
[Works for me。](http://jsbin.com/uxiziq)(在Firefox上)。 – kennytm 2012-03-14 10:30:44
这个脚本是否包含在第一个按钮之后,但在其他按钮之前?或者你在执行这个函数后用Ajax加载其他按钮?这个代码本身没有任何问题。 – 2012-03-14 10:34:41