IE浏览器提示对象不支持“append”属性或方法
如下代码在IE浏览器中无法执行,提示对象不支持“append”属性或方法
var tImg = document.createElement("img"); tImg.setAttribute("src", src); tImg.setAttribute("class", "img-rounded"); var tBr = document.createElement("br"); var tName = document.createElement("span"); tName.innerText = $(data).attr("name"); tName.style = "font-size:12px;font-family:sans-serif;font-weight:700;"; var tDiv = document.createElement("div"); tDiv.setAttribute("class", "col-xs-6 col-sm-4 col-md-2 col-lg-2 text-center"); tDiv.append(tImg, tBr, tName); $("#content").append(tDiv);
做如下修改,就可以了
var tImg = "<div class='col-xs-6 col-sm-4 col-md-2 col-lg-2 text-center'><img src='" + src + "' class='img-rounded' /><br/><span style='font-size:12px;font-family:sans-serif;font-weight:700;'>" + $(data).attr("name") + "</span></div>" $("#content").append(tImg);