3

Assuming that I have 1 button "Red" and multiple buttons behind:

<button type="button">Red</button>
<button type="button">ABC</button>
<button type="button">DEF</button>
<button type="button">GHI</button>
<button type="button">JKL</button>

Somehow, they are stacked on each others. But button "Red" is on top.

enter image description here

Would it be possible that clicking on "Red" will trigger events on itself and on all buttons behind?

Using CSS "pointer-events:none;" therefore doesn't work here. As well this is a general case, so using jQuery selectors to manually select and trigger them should be ruled out.

0

2 Answers 2

1

You can use trigger() to trigger the click event of green and blue button when you click on redbutton:

$('button.red').click(function () {
    $('button.green').trigger('click'); // or .click()
    $('button.blue').trigger('click'); // or .click()
});

Fiddle Demo

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

3 Comments

Well, I should rephrase my question as: Let's say I have a red button on top, and many other elements behind which I don't know. I just simply want that when I click the red button, the action will apply to it as well as transfer to all the other elements behind.
@tommyogp .You can use siblings selector. $("button.red").siblings().trigger("click");
@tommyogp You can use: $("button.red").siblings('button').trigger("click"); You can read more about siblings() from: api.jquery.com/siblings
0

Try putting them in css class. If you want to use javascript jquery, do .click() and activate all of them

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.