Interest in //Web //Win //Mobile //Database & //Life

7

Internet Explorer Object doesn’t support property or method ‘preventDefault’

I was working on a web page where I need to show or hide a div on button click using jquery, very simple code like below:

$(function () {
     $('#btntest').click(function () {
           event.preventDefault();
           $('#testdiv').toggle();
     });
});

 

it was working fine in chorme browser, but in IE  I get the error like Object doesn’t support property or method ‘preventDefault’

at first I started thinking is it a problem of IE, but as Jquery is well established library I had to think that there is something wrong in my code, then I started checking and I found without passing the event object parameter in the function and I was calling event.preventDefault();

so the fixing was also very simple I just have to pass the event object as parameter…

$(function () {
     $('#btntest').click(function (event) {
           event.preventDefault();
           $('#testdiv').toggle();
     });
});

 

Java ScriptJquery

Md Shiefuzzaman • April 24, 2013


Next Post

Comments

  1. бнанс March 26, 2024 - 9:54 am Reply

    Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

  2. Pumarehistro April 1, 2024 - 12:54 am Reply

    Thanks for sharing. I read many of your blog posts, cool, your blog is very good.

  3. registro de Binance April 1, 2024 - 8:08 pm Reply

    I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.

  4. Bonus Pendaftaran di Binance April 3, 2024 - 5:23 am Reply

    Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

  5. Binance注册 April 4, 2024 - 2:45 am Reply

    Thanks for sharing. I read many of your blog posts, cool, your blog is very good.

  6. 100 USDT алу шн тркелу April 4, 2024 - 7:58 pm Reply

    I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.

  7. izveidot binance kontu April 5, 2024 - 9:41 am Reply

    Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.

Leave a Reply

Your email address will not be published / Required fields are marked *