日期:2014-05-16 浏览次数:20514 次
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("p").click(function(){
$("#demoTable").append("<input type='button' id='btn1' value='按扭' onclick='test(this)' />");
});
});
function test(e) {
alert($(e).attr('id'));
$(e).hide();
}
</script>
</head>
<body>
<table id="demoTable">
</table>
<p>如果您点击我,我会消失。</p>
<p>点击我,我会消失。</p>
<p>也要点击我哦。</p>
</body>
</html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type='text/javascript'>
$(function(){
for(var i=0;i<5;i++){
$('#demoTable').append("<tr><td><input name='' type='button' value='test'/></td></tr>");
}
$('#demoTable input').live('click',function(){
alert(123);
});
})
</script>
<table id="demoTable">
</table>