Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 276
Max Lindner Avatar asked Aug 28 '26 02:08

Max Lindner


1 Answers

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

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

like image 95
Shivani Avatar answered Aug 30 '26 16:08

Shivani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!