我使用JQuery .html()函数在我的页面上插入字段。这些字段有一个类属性,但它看起来像在页面的标题部分声明的CSS不适用于该元素。CSS不应用于Javascript创建元素
我相信它只是影响类选择器,因为我有一个#editZone输入选择器,它像一个魅力一样工作。
下面是一个代码示例:
<!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>
下面是内容样品(来自萤火虫):
<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>
...
问题是关于jQuery,但你不显示你的jQuery代码? –
适合我。 http://jsfiddle.net/tomprogramming/yka2w/ –
那么考虑到内容确实填充,我不想用JavaScript代码工作的问题... – FMaz008