javascript - JQuery event.stopPropagation() not working -
In my HTML, I have a class drag handle gap which is embedded inside a li.
& lt; Div class = 'treeView' & gt; & Lt; Ul class = 'tree' & gt; & Lt; Li & gt; & Lt; Span class = "dragHandle" & gt; & Lt; / Span & gt; Item 1 & lt; Ul & gt; & Lt; Li & gt; & Lt; Span class = "draghandle" & gt; & Lt; / Span & gt; Item 2 & lt; A href = "#" & gt; Link & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; / Ul & gt; I add event handlers using jQuery as follows:
$ (". Tree tree"). Click (function (event) {alert ("click"); Event.stopPropagation ();}); $ ("Dragheadhandle"). Mosudown (event) {warning ("down"); event.stopPropagation ();}); $ ("DragHandle"). Mousewipe (function) {warning ("up"); event.stopPropagation ();}); When I move the mouse and mouse over the element, I get further alerts, although I get a click alert of Lee's event handler. I thought this call should be stopped from the event. In the stupprogication, in the Musudown and mouseup operators How do I stop click events called for mousedown / up events on dragheads?
TIA, Adam
I'm going to have the mouse / How to stop click event called?
Capture you ... and eat ... that event:
$ ("DragHandle"). Click (function (event) {event.stopPropagation ();}); The key here is thatas aclick,mozudown, andmouseupare different events, even though you < Code> clickMousewaidownasmouseup, you can actually haveclickEvents arising from user actions that do not include the mouse, as well as the combination ofmousedownandmouseup, which is not the result ofby clicking NotEvents found.
Comments
Post a Comment