页面后添加内容 点击移动
2012-05-06 16:07
281 查看
第一种写法:
<script type="text/javascript">
$(function(){
for(var i=0;i<5;i++){
$("<span>存在"+i+"</span>").appendTo("#existence");
}
for(var m=0;m<5;m++){
$("<span>不存在"+m+"</span>").appendTo("#unExistence");
}
$("#existence span").live("click", function() {
$(this).appendTo("#unExistence");
})
$("#unExistence span").live("click",function(e){
$(this).appendTo("#existence");
})
})
</script>
第二种写法:
for(var i=0;i<5;i++){
$("<span>存在"+i+"</span>").appendTo("#existence").click(function(e){
if($(this).parent().attr("id")=="unExistence"){
$(this).appendTo("#existence");
}else{
$(this).appendTo("#unExistence");
}
e.stopPropagation();
});
}
for(var m=0;m<5;m++){
$("<span>不存在"+m+"</span>").appendTo("#unExistence").click(function(e){
if($(this).parent().attr("id")=="unExistence"){
$(this).appendTo("#existence");
}else{
$(this).appendTo("#unExistence");
}
e.stopPropagation();
});
}
<script type="text/javascript">
$(function(){
for(var i=0;i<5;i++){
$("<span>存在"+i+"</span>").appendTo("#existence");
}
for(var m=0;m<5;m++){
$("<span>不存在"+m+"</span>").appendTo("#unExistence");
}
$("#existence span").live("click", function() {
$(this).appendTo("#unExistence");
})
$("#unExistence span").live("click",function(e){
$(this).appendTo("#existence");
})
})
</script>
第二种写法:
for(var i=0;i<5;i++){
$("<span>存在"+i+"</span>").appendTo("#existence").click(function(e){
if($(this).parent().attr("id")=="unExistence"){
$(this).appendTo("#existence");
}else{
$(this).appendTo("#unExistence");
}
e.stopPropagation();
});
}
for(var m=0;m<5;m++){
$("<span>不存在"+m+"</span>").appendTo("#unExistence").click(function(e){
if($(this).parent().attr("id")=="unExistence"){
$(this).appendTo("#existence");
}else{
$(this).appendTo("#unExistence");
}
e.stopPropagation();
});
}
相关文章推荐
- 点击添加按钮,关闭对话框,回到主住页面自动加载新添内容
- 输出带有是/否的对话框,实现效果是:点击是,继续添加内容,点击否,返回自己定义的页面
- 动态添加到页面的内容怎么写他们的点击事件
- Android-ListView中添加Button或者可点击TextView进行页面跳转
- dwz框架的table,页面初始化用ajax获取并设置表格内容后,表格没有点击事件等。
- jquery, 点击页面元素,使其移动到浏览器顶部,再点击还原。
- 根据页面edittext的内容控制按钮可点击状态
- 使用MasterPage(母版页)的ASP.NET Content(内容)页面添加CSS样式
- 页面点击打印按钮打印相关内容的小功能
- iOS移动中按钮添加点击事件
- 自己写的基于JavaScript DOM 仿一些页面的鼠标移动显示相应区块内容
- 基于jquery实现select选择框内容左右移动添加删除代码分享
- Android 自定义切换卡功能,通过intent跳转到添加内容页面
- 1怎样让输入的text文本填写的部分只添加数字、2怎样将输入的数字一次性全部删除 3怎样选择密码 让它不显示 4 怎样实现在没有return的情况下点击button的情况下就能够使键盘页面下落5 怎样实现点击指定的button来对使指定的text进行键盘弹出 6怎样改变button按钮的状态
- 为ckeditor添加事件,并得到ckeditor中的内容,点击重置使编辑器置空
- [11]UITableView编辑 删除 添加 移动 单例 及其去掉TableView没内容的Cell
- 在导航栏里,点击节点,触发页面刷新,重新读取数据库,并重新进行控件内容绑定,速度很慢,如何解决
- PDF文档如何添加、删除或移动页面
- Django 开发学习笔记(8)- 开发表单页面,让用户添加内容
- HTML-通过点击网页上的文字弹出QQ添加好友页面