基本上,我試着編碼以下內容。 (請注意,我在jQuery的新手,努力學習。)從ajax返回值的函數?
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<style>
img.box:hover { opacity: 0.4; }
</style>
<script type="text/javascript">
jQuery(document).ready(function()
{
$(".box").click(function(event){
$.post("./itemdrop.php", { id: "Item:1" }, function(data){
$('#box').append(data);
}
);
});
$("li").click(function(event){
$(".box").append("clicked");
})
});
</script>
</head>
<body>
<div id="box">
<img class="box" src="./img/box.jpg" width="150" height="150">
</div>
</body>
</html>
它應該是這樣的:在「盒子」形象
- 用戶點擊,jQuery的從itemdrop.php 得值
返回的值是<li class="item">Shield of Walmar</li>
然而,當我點擊S上的jQuery不採取行動沃爾瑪的領域。 (我不知何故有一種感覺,就是頂部的文檔就緒功能導致它。)
我該如何解決這個問題?
謝謝。解決了它。 :) – Aristona 2012-04-21 19:24:15