Making a jQuery selection in IE on html added via .load()
- by Joel Crawford-Smith
Scenario: I am using jQuery to lazy load some html and change the relative href attributes of all the anchors to absolute links.
The loading function adds the html in all browsers.
The url rewrite function works on the original DOM in all browsers.
But
In IE7, IE8 I can't run that same function on the new lazy loaded html in the DOM.
//lazy load a part of a file
$(document).ready(function() {
$('#tab1-cont')
.load('/web_Content.htm #tab1-cont');
return false;
});
//convert relative links to absolute links
$("#tab1-cont a[href^=/]").each(function() {
var hrefValue = $(this).attr("href");
$(this)
.attr("href", "http://www.web.org" + hrefValue)
.css('border', 'solid 1px green');
return false;
});
I think my question is: whats the trick to getting IE to make selections on DOM that is lazy loaded with jQuery?
This is my first post. Be gentle :-)
Thanks,
Joel