Max Lindner
Max Lindner

Reputation: 29

How can I separate two events in Javascript

I Have a <div> Element, which includes a Button. enter image description here

Both have Events. Code for the Button:

<button Title="Auswahl anzeigen" class="PopUpButton2" onClick="findArticlesFromSearchBoxButton()">OK</button>');  

Code for the Div-Element:

<div draggable="true" Title="aus aatentechnichen Gr&uuml;nden &#10; k&ouml;nnen beide Suchmethoden &#10; noch nicht miteinander kombiniert werden!" onMouseDown="dragStart(this);" id="divArtikelart">

When I click to the button also the clicks on die div-Elements are executed. How can i avoid this?

Upvotes: 3

Views: 292

Answers (1)

Shivani
Shivani

Reputation: 347

$("button").click(function(event){
    event.stopPropagation();
});

Add stopPropogation at first line in your button click function. this should resolve issue

Upvotes: 3

Related Questions