我有我的這些形式的按鈕,我想結合「的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