Jquery append chokes on quotes in ei
This jQuery statement works in recent versions of Firefox and Chrome, but throws an error in IE 8.
left_bar_string = "<tr><td><a href='#' onclick= "return newPopUpWindow('somelink','window', '1000','800','100','0','yes')">Directions</a></td></tr>";
$("#side_bar").append(left_bar_string);
I think the problem is with the double quotes. Any comments / solutions?
+2
a source to share
1 answer
This is a good example of why DOM manipulation can be used for this rather than innerHTML:
var tr = $("<tr>");
var td = $("<td>").appendTo(tr);
$("<a>").text("Directions").attr("href", "#")
.attr("onclick", "return newPopUpWindow('somelink','window', '1000','800','100','0','yes')")
.appendTo(td);
$("#side_bar").append(tr);
Basically everything will be the right escape for you.
+1
a source to share