0

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.

3
  • 3
    First of all change the ids of div. Id should never start with a number. Commented Dec 8, 2009 at 10:35
  • 2
    Some codes will be great to start the ball rolling. Commented Dec 8, 2009 at 10:37
  • Numbers in the IDs are just an example Commented Dec 8, 2009 at 11:42

3 Answers 3

4

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

Sign up to request clarification or add additional context in comments.

Comments

4

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.

1 Comment

The name of the function is dynamic. I mentioned it in the problem
1

using jQuery you could do something like this

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.