Madhu
Madhu

Reputation: 5766

Problem with Css & Javascript

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.

Upvotes: 0

Views: 100

Answers (3)

NDM
NDM

Reputation: 6830

using jQuery you could do something like this

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

Upvotes: 1

Vincent Ramdhanie
Vincent Ramdhanie

Reputation: 103135

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

Upvotes: 4

Guillaume Flandre
Guillaume Flandre

Reputation: 8980

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.

Upvotes: 4

Related Questions