[英]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.