简体   繁体   English

如何在jquery中除first 1之外的所有元素绑定事件

[英]how to bind event on all elements except first 1 in jquery

I want to bind hover event on all .menu class element except first element for this i wrote the following code : 我想在所有.menu class元素上绑定hover事件,除了first element ,我写了下面的代码:

        $(".menu:not(:first-child')").hover(function () {
        },
        function () {
        });

But this is not working. 但这不起作用。 Whats the problem ? 有什么问题 ?

$(".menu").not(":first-child")

要么

$(".menu").not(":eq(0)")

jQuery's slice method jQuery的slice方法

$('.menu').slice(1).hover(function () {
    // in
}, function () {
    // out
});​

Just to be different... 只是为了与众不同......

使用此代码:

$('.menu').not(":first")
 $(".menu:not(:first)").hover(function() {

 },
 function () {
 });

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

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