我正在尝试在JQuery中创建一个简单的ToDo列表,但我遇到了一个问题.我创建了函数'deleteListItem',我使用它来删除我的列表项:
$(this).parent().remove();
Run Code Online (Sandbox Code Playgroud)
,然后我想将fadeOut效果添加到我的列表中,所以我尝试了:
$(this).fadeOut(1000, function(){
$(this).parent().remove();
})
Run Code Online (Sandbox Code Playgroud)
,但这个fadesOut只是我的删除按钮所以然后我试过
$(this).parent().fadeOut(1000, function(){
$(this).parent().remove();
})
Run Code Online (Sandbox Code Playgroud)
这会消除我所有的'ul',而不仅仅是'li'元素.这是我的JSBIN,所以你更好地理解我在做什么:http://jsbin.com/ciyufi/edit?html,js,output
在回调处理程序内部,this指的是<li>.
$(this).parent().fadeOut(1000, function(){
$(this).remove();
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
278 次 |
| 最近记录: |