tags:

views:

60

answers:

3

Hello,

I am having nested DIV's. Below is the Example.

<div id="one">
    <div id="two">
    </div>
</div>

I am calling a javascript function when we click on div one and div two.

Now the problem is sometimes the size of div two is large so that div one goes behind div two. Actually if i click div two i want to call both div one and div two. Since the javascript function name is dynamic, i am stuck.

Any idea how to call both js functions when we click div 2.

+4  A: 

At the end of div 2's click handler, you could call div 1's.

UPDATE:

What I meant is you could fire a click event on div 1 when div 2 is called.

Guillaume Flandre
The name of the function is dynamic. I mentioned it in the problem
Madhu
Yes my answer wasn't clear, sorry about that, I updated it
Guillaume Flandre
+4  A: 

You might find the discussion here interesting. It gives good explanation and examples of event bubbling and propagation.

Vincent Ramdhanie
His book is good too. +1
Mark Dickinson
+1  A: 

using jQuery you could do something like this

$('div2').click(function() {
    $(this).parent().click();
}
Nicky De Maeyer