简体   繁体   中英

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

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

Just to be different...

使用此代码:

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

 },
 function () {
 });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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