[問題] 控制以AJAX插入的東西…
┌─────┐
│index.htm │
└─────┘
…
<style>
#aaa{
background: red;
width: 200px;
height: 200px;
}
</style>
<script>
$(function(){
$.post("demo.php",{id:"aaa"},function(result){
$("#bbb").html(result);
});
$("#aaa").on('click', function(){
alert("Hello world!");
});
});
</script>
<div id="bbb"></div>
…
┌────┐
│demo.php│
└────┘
<div id='<? echo $_POST['id']; ?>'></div>
==========
大家好,
以上範例我想讓一個id為aaa的<div>以AJAX的方式插入於id為bbb的<div>中
插入後會看到一紅色方塊
但問題是我想讓使用者按下那紅色方塊後可以跳出一警告方框
Javascript好像不允許控制以AJAX插入的東西
請問該怎麼解決這問題?
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 101.138.145.92
※ 文章網址: https://www.ptt.cc/bbs/Ajax/M.1471613513.A.5FD.html
推
08/19 22:04, , 1F
08/19 22:04, 1F
→
08/19 22:05, , 2F
08/19 22:05, 2F
→
08/19 22:05, , 3F
08/19 22:05, 3F
→
08/19 22:05, , 4F
08/19 22:05, 4F
→
08/19 22:06, , 5F
08/19 22:06, 5F
→
08/19 22:06, , 6F
08/19 22:06, 6F
→
08/19 22:07, , 7F
08/19 22:07, 7F
→
08/19 22:07, , 8F
08/19 22:07, 8F
→
08/19 22:08, , 9F
08/19 22:08, 9F
→
08/19 22:08, , 10F
08/19 22:08, 10F
→
08/19 22:09, , 11F
08/19 22:09, 11F
→
08/19 22:09, , 12F
08/19 22:09, 12F
→
08/19 22:09, , 13F
08/19 22:09, 13F
→
08/19 22:09, , 14F
08/19 22:09, 14F
→
08/19 22:10, , 15F
08/19 22:10, 15F
→
08/19 22:10, , 16F
08/19 22:10, 16F
→
08/19 22:10, , 17F
08/19 22:10, 17F
→
08/19 22:11, , 18F
08/19 22:11, 18F
推
08/20 22:33, , 19F
08/20 22:33, 19F
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章