Thursday, February 17, 2011

jQuery .empty() "'events' is null or not an object"

If you're not on the latest version of jQuery (1.4.2 or earlier), you may experience an error with the .empty() method, "'events' is null or not an object". This bug is fixed in later versions, but if you're like me, your project doesn't allow you to plug a new version in.

Luckily, there is an easy fix. Just use .html() to set the HTML to an empty string.

$("#div").html("");

This will acheive the same result and you can keep on using your currently installed jQuery file.

Enjoy.

1 comment:

  1. Good article.I really think what you said is right,in modern society,we have so many troubles,if you feel nothing to relax yourself,I suggest you to play the wow and some other games,and you can come to my page to find more information about http://www.mmolive.com/ and http://www.mmohome.com/gold/Guild-Wars-2-US.html/

    ReplyDelete