allow clicking of child element in div with overlaying link

Go To StackoverFlow.com

0

So basically, I have a jQuery accordion. I arranged the content so that it appears inside bounding box (header) of the accordion. I have several items that have href's tied to them within the content. Problem is that I can't click through the accordion header because it is also clickable obviously.

It looks like this:

---------------------------
- (top layer)             -
-                         -
-   ------------------    -
-   - (bottom layer) -    -
-   - click me!      -    -
-   ------------------    -
-                         -
---------------------------

So I can just bind a click event to the bottom layer but I'd really love to avoid doing so. What are the options?

2012-04-04 18:07
by Jared Eitnier
Probably using some sort of stopPropagation will work, but there is no code posted, so it's impossible to tell really - adeneo 2012-04-04 18:11
Not sure I got the question, but are you trying to click on elements that are behind other elements, if so, why - adeneo 2012-04-04 19:06


0

Taken from http://cmar.me/2011/06/15/links-in-jquery-accordion-headers/

$('content .image a').click(function() {
    window.location = $(this).attr('href');
    return false;
});

Not what was originally requested but simple enough to live with.

2012-04-04 18:27
by Jared Eitnier


2

You can prevent it by OnClick="preventAction(event)" and in JS

function preventAction(e) {
       e.preventDefault();
}
2012-04-04 18:11
by Dion
I should be more clear. The top level is not an href, just a regular div, preventDefault() will have no effect I think - Jared Eitnier 2012-04-04 18:23
Ads