jquery Event.stopPropagation() seems not to work

Live events don’t follow the same event bubbling rules. See the documentation on live event handling. Quote from reference above: Live events do not bubble in the traditional manner and cannot be stopped using stopPropagation or stopImmediatePropagation. For example, take the case of two click events – one bound to “li” and another “li a”. … Read more

Javascript attach an onclick event to all links

It’s weird that nobody offered an alternative solution that uses event bubbling function callback(e) { var e = window.e || e; if (e.target.tagName !== ‘A’) return; // Do something } if (document.addEventListener) document.addEventListener(‘click’, callback, false); else document.attachEvent(‘onclick’, callback); The pros of this solution is that when you dynamically add another anchor, you don’t need to … Read more

How to create user define (new) event for user control in WPF ?one small example

A brief example on how to expose an event from the UserControl that the main window can register: In your UserControl: 1 . Add the following declaration: public event EventHandler UserControlClicked; 2 . In your UserControl_Clicked event raise the event like this: private void UserControl_MouseDown(object sender, MouseButtonEventArgs e) { if (UserControlClicked != null) { UserControlClicked(this, … Read more

Prevent onclick action with jQuery

jQuery is not going to solve this one OOTB. It can help, but none of stopPropagation, stopImmediatePropagation, preventDefault, return false will work if you simply attach them to the element. You need to override the element’s click handler. However you state in your question “without removing onclick actions”. So you need to override the default … Read more

Detect user scroll down or scroll up in jQuery [duplicate]

To differentiate between scroll up/down in jQuery, you could use: var mousewheelevt = (/Firefox/i.test(navigator.userAgent)) ? “DOMMouseScroll” : “mousewheel” //FF doesn’t recognize mousewheel as of FF3.x $(‘#yourDiv’).bind(mousewheelevt, function(e){ var evt = window.event || e //equalize event object evt = evt.originalEvent ? evt.originalEvent : evt; //convert to originalEvent if possible var delta = evt.detail ? evt.detail*(-40) : … Read more