[問題] 用Jquery的ajax方法傳回來的物件,怎麼在上面再用jquery
我現在有一個問題
首先在原來的html的
<div id="this_month" showed="false">
按此顯示本月
</div>
加上 click事件,並且click事件加上ajax
jquery碼如下:
$(document).ready(function() {
$('div#this_month').click(function(event){
var html = $.ajax({ url:
"getHour.aspx?tb=<%=HourTB%>&case=month&day="+day_str,error:function(){
alert("Ajax 要求發生錯誤");
},beforeSend:function(){
$('#loading').show();}, complete: function(){
$('#loading').hide();}, async: false }).responseText;
$('#this_month').html("");
$('#this_month').hide();
$(html).insertAfter('#this_month').slideDown("slow");
;
$('#this_month').attr('showed',"true");
});
});
Jquery也正確在this_month上顯示ajax傳回的文字:
<span class="return" >回傳值</span>
可是現在問題來了
我直接在$(document).ready(function() {});加上
$('.return').click(function (event){
alert("回傳內容");
return false;
})};
並不會發生作用
可是如果我直接在回傳的span裡面加上onclick事件,就會發生作用
所以我的問題,我要如何讓回傳的物件可以使用jquery事件
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.228.153.178
推
10/28 18:09, , 1F
10/28 18:09, 1F