我的代码:
<script>
function abc(){
for (var i = 0; i < 3; i ++)
{
var t = $('<li></li>').text(i);
$("ol").prepend(t);
}
}
$(document).ready(function(){
$("li").click(function(){
$(this).hide();
});
});
</script>
HTML:
<body>
<button onclick = "abc()">asdf</button>
<p>If you click on me, I will disappear.</p>
<ol>
<li>Click me away!</li>
<li>Click me too!</li>
</ol>
</body>
为什么当我点击创建的 (li) - 它不隐藏?我该怎么做?