How to distinguish Outermost Accordion vs nested Accordions click event using Jquery

user663724

I have a JSFiddle

http://jsfiddle.net/UD5eY/2/

which shows two Accordions on start up namely Students and Employees and these Accordions can have nested Accordions .

Is it possible to get an alert (click event fired ) when clicked on Students or Employees (I mean for outermost Accordions only) because I have a seperate logic when nested Accordion is clicked and seperate logic when the outermost Accordion is clicked.

I have used

which is actually getting fired up for all Accordions including nested also .

$("div.accordian").accordion({
    activate: function (event, ui) {
        setStuff(event, ui);
    }
});
mituw16

Easiest thing I could think of off the top of my head would be to just add a class to your outer most accordion, and then listen to the click event of those.

Try something like this. http://jsfiddle.net/UD5eY/3/

HTML

<h3><a href="#" class="Outer">Students </a></h3>
<div id="inner"></div>

<h3><a href="#" class="Outer">Employees </a></h3>
<div id="inner"></div>

JS

$(".Outer").parent().click(function() {
    //do codez!
    alert("hello");
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to ignore jQuery accordion click event for the nested <a>

jQuery accordion event on click

How to collapse all the nested Accordions if clicked on its parent Accordion?

On click of an accordion should close other accordions

how to distinguish button in tableviewcell click event and tableviewcell click event

How to Trigger an event on button click using jQuery

How to catch click event is finished using Jquery?

How to detect click event in iframe using jquery

Select accordion-toggle in nested collapse to fully close accordions

jQuery .click() function how to distinguish table rows

Issue when using a loop for accordion with JQuery event

Make Jquery Accordion script to allow multiple accordions on one page

Bootstrap accordion, scroll to top of active accordion on click, how will i implement on nested accordion?

Nested jquery accordion is not working

jQuery Bootstrap Nested Accordions: How to collapse child items when parent is closed

How to distinguish the WM_LBUTTONUP message in a single-click event and a double-click event

How to know which type of Html object is using jQuery click event?

How to detect click event on any checkbox on a page using jQuery?

How to remove all click event handlers using jQuery?

How to call jquery click event using C#

How to write code for firefox click event using Jquery

How to select next ul on click event using jQuery

How to detect a click event to an inner div using Jquery

How to append <li> to another <ol> on click event using jquery?

How to get click event in code behind in c# using jquery

How can values be appended into an Empty Array using click event in JQuery

How to differentiate the click function for nested element tag using jQuery?

How to distinguish between left and right mouse click with jQuery

How to toggle accordion using Javascript/jquery