[jQuery] IE and selectors
I've a strange problems with IE (currently, IE6. Don't know IE 7):
I've got this method:
function iSMSfixIEHistory()
{
var temp;
$("#log").append("Function called
");
$.each($("a[href^='#']"), function() {
temp = $(this).attr("href").replace(/\#/, "stupidIE.php?query=");
$(this).attr("href",
'javascript:document.getElementById("stupidIEiframe").setAttribute("src",
"'+temp+'")');
$("#log").append(temp+"
");
});
}
It's working correctly in Firefox.
It works in IE only for elements that weren't created using
javascript. Let me explain:
This method has to be executed when the page loads and when new links
are added dinamically to the page (after a AJAX call). For the first
ones, it works perfectly, but the second ones aren't found.
This is how I create new links:
for(key in use_list)
{
list += '<li><a href="#contact.' + use_list[key][0] + '">' +
use_list[key][1] + "</a></li>";
}
(then I add list contents to the page using $("#content").html(list) )
I've made a log:
This is what looks like in Firefox (and what should be):
Function called
stupidIE.php?query=import
stupidIE.php?query=prefs
stupidIE.php?query=home
stupidIE.php?query=contact.3
stupidIE.php?query=contact.1219
stupidIE.php?query=contact.1148
stupidIE.php?query=contact.53
stupidIE.php?query=contact.29
stupidIE.php?query=contact.15
stupidIE.php?query=contact.38
(etc)
But this is what happens in IE:
Function called
stupidIE.php?query=import
stupidIE.php?query=prefs
stupidIE.php?query=home
Function called
(the first three were in HTML code)
Is it a jQuery bug? How could I solve it?
Thank you