IE 7 can't bind event (using .live()) to dynamically created element using .load()
- by petron
Hi All - I'm having trouble getting IE7 to keep a click event bound to an element that is added to the DOM using .load(). Here's some code:
$('.mybtn').live('click', function(e){
e.preventDefault();
$('#mypage').load('load-this-page.htm');
});
And here's the html
<div id="mypage">
<a href="#" class="mybtn">clickme</a>
// stuff goes here
</div>
On page load the click works but once the div is loaded via the clickme link the click stops working in IE7. The clickme link is within the div on load and also within the load() loaded html file that's why I'm using live().
This code works in FF 3.6, fyi.
Anyone have any idea what's up (besides the fact the IE sucks balls)? Thanks!