我試圖添加其他<a>
元素後<a id='link1'>
jQuery的 - 不是動態的元素創建
<html>
<head>
<script src="js/jquery-1.6.4.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
var myHTML = "<div id='test'>";
myHTML += "<span><a id='link1'>link 1</a></span>";
$("a#link1").after("<a id='link2'>link 2</a>");
myHTML += "</div>";
$("div#insertHere").html(myHTML);
});
</script>
</head>
<body>
<div id="insertHere">
</div>
</body>
</html>
的輸出上面應該是
<body>
<div id="insertHere">
<div id="test">
<span>
<a id="link1">link 1</a>
<a id="link2">link 2</a>
</span>
</div>
</div>
</body>