Skip to main content

Bug Tracker

Side navigation

#7492 closed bug (worksforme)

Opened November 12, 2010 06:57PM UTC

Closed November 12, 2010 08:18PM UTC

$(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:

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 + '"';



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>";




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.

Attachments (0)
Change History (1)

Changed November 12, 2010 08:18PM UTC by boushley comment:1

resolution: → worksforme
status: newclosed

I think I've parse what you said in your ticket into this jsFiddle 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="" target="_blank">Lees meer.</a></p>"