Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
e.preventDefault() is not working with mousedown event?

I have written below code to prevent click event. Its working as expected with below code.

$(".k-grid-filter").on('mousedown', function (e) {
    var editRow = $(this).closest(".k-grid").find(".k-grid-edit-row");
    if (editRow.length > 0) {
        e.preventDefault();
        e.stopImmediatePropagation();
        alert(e.type);
    }
});

But I don't want to display alert pop-up. If I remove alert(), preventDefault() is not working.

$(".k-grid-filter").on('mousedown', function (e) {
        var editRow = $(this).closest(".k-grid").find(".k-grid-edit-row");
        if (editRow.length > 0) {
            e.preventDefault();
            e.stopImmediatePropagation();
        }
    });

Can anybody please help me to find is missing and what has to be done to make is work? Thanks in advance :)

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Neither of mouseup or mousedown prevent the default click event.

See this answer for more details.

about 4 years ago · Juan Pablo Isaza Report

0

You can't use e.preventDefault() in mousedown and mouseup event because the function only works on click you have to select that part.

The mousedown event is fired at an Element when a pointing device button is pressed while the pointer is inside the element.

you can check reference of this link here

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!