[英]CSS Background image not showing IE8
我有以下CSS代码
#gel{position:absolute; width:20px; height:22px; margin-left:5px; color:#FF0000;background:url('../images/GEL-CURENCY.jpg') repeat-x;background-color:transparent;}
这是我的剧本
document.getElementById("small_txt_container_2").innerHTML = '<span id=\"gel\"></span>';
在IE 8中无法正常工作,请帮助我解决此问题
如果问题仅在IE8中,则在<head>
包含此逻辑
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
innerHTML
是指HTML标记内的内容,而不是标记本身。 查看此示例,它将帮助您了解如何使用纯JS在页面中添加新的<span>
。
(function(){
// 1- Establish new element
var newItem = document.createElement('span');
// 2- Add className
newItem.className = 'gel';
// 3- Put content into <span> tags
newItem.innerHTML = 'stuff inside the brackets';
// 4- Tell your program to put the span just after an item with your-ID-here
document.getElementById('your-ID-here').appendChild(newItem);
})();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.