您的位置:首页 > 其它

页面后添加内容 点击移动

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();

});

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐