首页 > Web开发 > 详细

IE8 innerHTML赋值时包含多级HTML标签时的解决方案

时间:2015-04-20 00:26:14      阅读:449      评论:0      收藏:0      [点我收藏+]
var inhtml = ‘‘;

var font = document.createElement("font");
var a = document.createElement("a");
var div = document.createElement("div");
font.style.fontSize = "18px";

if (str == 0) {

font.style.color = "#33CC33";
font.innerHTML = "恭喜你,都答对了,请进入下一题库";
a.href = "/index.php/onlinecource/retroaction/id/" + cat_id;
a.className = "answer_a";
div.appendChild(a);

} else {

font.style.color = "#97171B";
font.innerHTML = "抱歉,第" + str + "题答错了,请查看正确答案后作出修改";
a.href = "/index.php/onlinecource/correctanswer/id/" + cat_id;
a.className = "noneanswer_a";
a.innerHTML = "正确答案";
div.appendChild(a);

}

txt.appendChild(font);

txt.appendChild(div);

document.getElementById(‘msgDiv‘).appendChild(txt);

以上JS代码是本人在之前项目里所经历过的,在这里与大家分享下,望能够帮助大家在遇到这类问题时可以快速得到解决!

IE8 innerHTML赋值时包含多级HTML标签时的解决方案

原文:http://www.cnblogs.com/wangyulu/p/4440297.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!