zoukankan      html  css  js  c++  java
  • IE8 innerHTML赋值时包含多级HTML标签时的解决方案

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

  • 相关阅读:
    [CF786B] Legacy
    [CF833B] The Bakery
    [JSOI2008] 最小生成树计数
    [SDOI2010] 外星千足虫
    [POJ1830] 开关问题
    [Luogu1365] WJMZBMR打osu! / Easy
    [Noip2016] 换教室
    [NOI2002] 荒岛野人
    [计蒜之道复赛 2018] 贝壳找房计数比赛
    [SDOI2014] 旅行
  • 原文地址:https://www.cnblogs.com/wangyulu/p/4440297.html
Copyright © 2011-2022 走看看