标签:
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