Opened 13 years ago
Closed 13 years ago
#7492 closed bug (worksforme)
$(element).html() output inconsistent in version 1.4.3
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | 1.5 |
Component: | unfiled | Version: | 1.4.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
It looks like that $(element).html()in version 1.4.3 returns inconsistent output. Using it with latest versions of FF, Opera, Chrome or Safari the output is identical. But in IE8 it is not. This is the code piece that I use.
get the href if any var itemHref = $(this).attr("href"); if (itemHref != "#") {
add the link to the end of the text var divText = itemDiv+" p:last"; var itemDivText = $(divText).html(); var itemHrefTarget = $(this).attr("target"); if (itemHrefTarget!="") {
itemHrefTarget=" target=" + '"' + itemHrefTarget + '"';
} else{
itemHrefTarget=" target=" + '"' + "_blank" + '"';
} var divLink ="<a href=" + '"' + itemHref +'"'+ itemHrefTarget + ">Lees meer.</a>"; only add it if not there yet if(itemDivText!=divLink) {
itemDivText=itemDivText + "<p>" + divLink + "</p>"; $(divText).html(itemDivText);
}
}
Running this in IE8 the value of itemDivText= ="<A href="Visie.html#Ankernaam2" target=_blank>Lees meer.</A>" (Yes caps and no quotes wrapped around _blank.) after adding divLink to the text.
In the other browsers itemDivText=="<a href="Visie.html#Ankernaam2" target="_blank">Lees meer.</a>" What it should be, because that is what the code sets it to when adding divLink to the text.
So I don’t know if it is something I am doing wrong or that it is the quirky behavior of IE8. To me it looks like a Jquery bug. Not cross browser compatible….:-( So hence the ticket.
Obviously in IE8 the link is always added, even if the link is already there. The link itself works fine in IE8 too by the way.
I think I've parse what you said in your ticket into this jsFiddle http://jsfiddle.net/boushley/KPyDE/ As far as I can tell things work fine. On IE 8 and Chrome at the console.log itemDivText is set to "<p><a href="http://www.google.com" target="_blank">Lees meer.</a></p>"