IE 7 can't bind event (using .live()) to dynamically created element using .load()
Posted
by petron
on Stack Overflow
See other posts from Stack Overflow
or by petron
Published on 2010-04-14T14:38:24Z
Indexed on
2010/04/14
14:43 UTC
Read the original article
Hit count: 181
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!
© Stack Overflow or respective owner