4

I am making cross-platform mobile site using html and jQuery for android, windows and iPhone devices .

The problem Is when I click on an element which is above another element then the click event is also triggered on below element.

I am having a custom popup which opens on center of page and having a button exactly below the button there is also a button on page with click event.

So on clicking the button on popup the event is also fired on button below the popup.

How to prevent this kind of events on Touch devices.

Same is the case with the drop-down when I select or click the option then the below button's click event get fired up.

enter image description here

Anirudha Gupta
  • 9,073
  • 9
  • 54
  • 79
Shashank.gupta40
  • 915
  • 1
  • 8
  • 26

1 Answers1

0

you should use event.stoppropagation():

$('your-element').on('click', function(e){
    e.stopPropagation();
    // other stuff here
})

That should solve your problem.

Atheist
  • 525
  • 3
  • 22