开发者

Problem with Css & Javascript

开发者 https://www.devze.com 2022-12-13 08:09 出处:网络
I am having nested DIV\'s. Below is the Example. <div id=\"one\"> <div id=\"two\"> </div>

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.

开发者_StackOverflow

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


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


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.


using jQuery you could do something like this

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号