[英]CSS not applying on Javascript created element
我使用JQuery .html()函数在页面上插入字段。 这些字段具有class属性,但是好像在页面标题部分中声明的CSS不适用于该元素。
我相信这只会影响类选择器,因为我有一个像###########################################
这是一个代码示例:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<style type="text/css">
#editZone input, #editZone textarea, #editZone select{
border:0px;
}
#editZone .dependant {
background-color:#CCC;
border-bottom:1px solid #333;
}
#editZone .original {
background-color:#FFF;
border-bottom:1px solid #300;
}
</style>
</head>
<body>
<div id="headZone">
Template:
<select id="template">
</select>
<input type="button" id="generateTpl" value="Go" />
</div>
<div id="editZone" style="background-color:#ccc;">content will be filled here upon template selection</div>
<div id="previewZone">final</div>
</body>
</html>
这是内容示例(来自Firebug):
<div style="background-color:#ccc;" id="editZone"><br>
<br>
Name - <input type="" class="original" value="" name="first_name" id="first_name_1"> <input type="" class="original" value="" name="last_name" id="last_name_1"><br>
Title<br>
...
您应该关闭html标签,然后我认为它应该可以工作。 关闭"<tagname />"
或"<tagname></tagname>"
类的标签。 我的意思是输入,br和所有打开的标签都没有关闭。
希望能帮助到你。
干杯
在样式声明中,我在类名和{之间有一个奇怪的空格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.