我是jquery和html的新手。我試圖插入在jquery中的代碼到html代碼中的class =「content」中,我檢查控制檯並且它到達loadDoc()函數。我用.html和.append試過這兩個都不行。使用jquery插入html代碼
HTML代碼
<section id="doc" class="main">
<div class="content">
</div>
</section>
jQuery代碼
function loadDoc(){
console.log("Load Doc");
var content = '<header>This is the header</header><article>' +
'<p>This is the content form loadDoc() </p></article>';
$("section#doc.content").append(content);
}
我很快就被重寫它應該在的問題我的道歉 – user3464613
loadDoc() @ user3464613明白了。看到我編輯的答案的第二部分 - 你的jQuery選擇器也有錯誤。 –