我使用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和所有打开的标签都没有关闭。
希望能帮助到你。
干杯