我試圖學習JQuery,但做得不好。目前,我正在嘗試學習如何使用.append
具有Ajax功能,以便在不重新加載的情況下查看新的動態內容。但是,當我嘗試以下時,什麼都不會發生。
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>JQuery Test</title>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
</head>
<body>
<div id="content"/>
<script type="text/javascript">
function callback() {
$("#content").append($("qwerty"));
};
$(document).ready(function() {
//window.setTimeout(callback, 100);
callback();
});
</script>
</body>
</html>
據我所知,這應該使「QWERTY」看起來好像我簡單地做了<div id="content">qwerty</div>
,而是我得到一個空白頁。如果我將.append
呼叫替換爲alert("qwerty")
,它會正確顯示。我究竟做錯了什麼?
@ tikiking1你的代碼做到這一點http://jsfiddle.net/arunpjohny/7jBcr/2/ –