1

I have this code:

$link.click(function (e) {
    debugger;
});

When the link is clicked and the debugger engages, e is a regular browser event, and not a jQuery event. There's no .stopPropagation() or .preventDefault().

Why is this?

3 Answers 3

1

Try

$link.bind("click", function (e) {
    var jQueryEvent = e,
        browserEvent = e.originalEvent;
});
Sign up to request clarification or add additional context in comments.

Comments

0

Because, as you said, it a regular browser event, and browser event doesn't have that kind of method.

To stop the propagation, just return false.

Comments

0

e should be an instance of jQuery.Event, so those methods should be available:

$("a").click(function(e) {
    alert(e instanceof jQuery.Event); // true
});

http://jsfiddle.net/dyJtY/

Can you provide more context, such as the debugger output?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.