jQuery click(function) not working

daftpanda

I'm trying to create a clickable sub-menu with slideDown() via jQuery. However - hover() is working as intended, but click() doesn't do anything.

Here's my jQuery:

$("#n_ulist li").click(function(){
    $("ul", this).stop().slideDown(500);
    },
    function() {
    $("ul", this).stop().slideUp(500);  
});

What is wrong here?

Pete

try the following instead:

$("#n_ulist li").click(function(){
    $(this).parent().find('ul').stop().slideUp(500);
    $("ul", this).stop().slideDown(500);
});

or if your menu is more than one level you may need to use

$('#n_ulist').find('ul').stop().slideUp(500);

EDIT

As per your comments

$("#n_ulist li").click(function(){
    $(this).parent().find('ul').stop().slideUp(500);
    $("ul", this).stop().slideToggle(500).click(function(e) {
        e.stopPropagation();
    });
});

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

jquery .animate is not working

분류에서Dev

Login with jQuery AJAX is not working

분류에서Dev

JQuery Parallax not working

분류에서Dev

JQuery not working on Joomla 3

분류에서Dev

jQuery .post() function not working

분류에서Dev

jquery post not working and no error

분류에서Dev

Jquery content slider not working

분류에서Dev

If condition not working in Javascript/Jquery

분류에서Dev

jQuery settimeout() not working correctly

분류에서Dev

Wordpress JQuery not working

분류에서Dev

jQuery validation not working with that form

분류에서Dev

jquery addClass is not working

분류에서Dev

else not working (Jquery)

분류에서Dev

Responsive jquery is not working correctly

분류에서Dev

addClass('open') is not working in jquery

분류에서Dev

Express: jQuery Validation not working

분류에서Dev

Jquery .next() not working as expected

분류에서Dev

jquery redirect on keydown is not working

분류에서Dev

jQuery Counter Not Working

분류에서Dev

Navigation bar jQuery not working

분류에서Dev

jQuery cookies not working at all

분류에서Dev

Jquery multiimage preview remove is not working

분류에서Dev

jQuery's get() function not working

분류에서Dev

jquery loop not working with php data

분류에서Dev

Google Maps not working using jQuery

분류에서Dev

jQuery is not working in IE7

분류에서Dev

Suddenly JavaScript/jQuery stopped working

분류에서Dev

My regex not working in jquery validationenging

분류에서Dev

jQuery UI not working in WordPress plugin