-2

I want to create two divs. Div A and Div B. Div A is on the top of Div B in such a way that Div A completely covers Div B . What I want to achieve is - Div A should be click-through so that I can click div B which is lying under Div A.

FYI- I don't want to hide div A. It should be there but one should be able to click right through it.

Any help appreciated. Thanks in advance.

Chris
  • 26,544
  • 5
  • 58
  • 71
Anoop Nair
  • 171
  • 1
  • 2
  • 13

1 Answers1

1

I suggested this for someone else looking for similar functionality. Use jQuery so that you are able catch the click event on the overlaying div and delegate it to the underlying div to simulate this

$(document).ready(function(){
   $('#myDiv').click(function(event){ 
     event.preventDefault(); 
     $('#myOtherDiv').trigger(event); 
   });

});

Something along those lines (either use .trigger or just .click on the underlying div)

Darius
  • 5,180
  • 5
  • 47
  • 62
  • 1
    What if the other DIV contains multiple elements, and the OP wants to have different click handlers for those elements? – Šime Vidas Oct 06 '12 at 15:19
  • 1
    The OP did not mention using jQuery. He should install it just for doing this one thing? – Sparky Oct 06 '12 at 15:20
  • If the underlying div contains multiple elements it could be a case of setting display:none or .hide() on click and refiring the event/simulating it at the event's co-ordinates? – Darius Oct 06 '12 at 15:26