当点击左边的li标签的时候,这边的li标签飞到右边去,点击右边的li标签飞到左边来,并且有顺序

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
#ulL
{
border: 2px dashed black;
width: 100px;
float: left;
}
#ulR
{
border: 2px dashed black;
width: 100px;
float: right;
}
.bgcolor
{
background-color: #0094ff;
}
</style>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(function () {
$("#ulL li").click(function () {
$(this).toggleClass("bgcolor");//每点击一次li标签则给标签加个背景颜色
}); //仅仅把选中的li标签飞到右边去
$("#btnRemove").click(function (e) {
e.preventDefault();
$("li").each(function () {
if ($(this).attr("class") == "bgcolor") {
$(this).css({ position: "absolute" }).animate({ left: document.body.clientWidth - 100 }, 2000, function () {
$(this).css({ position: "static" }).appendTo("#ulR").toggleClass("bgcolor");
});
}
}); /* 当点击左边的li标签的时候飞到右边,点击右边的飞到左边,并且按照原来的顺序排列
if ($(this).parent().attr("id") == "ulL") {
$(this).css({ position: "absolute" }).animate({ left: document.body.clientWidth - 100 }, 1000, function () {
$(this).appendTo($("#ulR")).css({ position: "static" });
var uList = $("#ulR li");
uList.sort(function (x, y) {
return parseInt(x.getAttribute("index")) - parseInt(y.getAttribute("index"));
}).appendTo($("#ulR"));
}); } else {
$(this).css({ position: "absolute" }).animate({ left: 100 }, 1000, function () {
$(this).appendTo($("#ulL")).css({ position: "static" });
var uList = $("#ulL li");
uList.sort(function (x, y) {
return parseInt(x.getAttribute("index")) - parseInt(y.getAttribute("index"));
}).appendTo($("#ulL"));
});
}
*/
});
});
</script>
</head>
<body>
<ul id="ulL">
<li index="1">●●●</li>
<li index="2">◆◆◆</li>
<li index="3">■■■</li>
<li index="4">▲▲▲</li>
<li index="5">★★★</li>
</ul>
<div>
<input id="btnRemove" type="button" value="移动" />
</div>
<ul id="ulR">
</ul>
</body>
</html>

html代码

js会飞的li标签的更多相关文章

  1. Jquery和JS获取ul中li标签(转)

    js 获取元素下面所有的li var content=document.getElementById("content"); var items=content.getElemen ...

  2. Jquery和JS获取ul中li标签

    js 获取元素下面所有的li var content=document.getElementById("content"); var items=content.getElemen ...

  3. 9会飞的li标签

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  4. js实现点击<li>标签弹出其索引值

    据说这是一道笔试题,以下是代码,没什么要文字叙述的,就是点击哪个<li>弹出哪个<li>的索引值即可: <html> <head> <style& ...

  5. 给li标签添加自定义属性

    给li标签添加属性<ul> <li></li> <li></li> <li></li> <li>< ...

  6. bootstrap中的动态加载出来的图片轮播中的li标签中的class="active"的动态添加移除

    //该方法是在slide改变时立即触发该事件, $('#myCarousel').on('slide.bs.carousel', function () { $("#myCarousel o ...

  7. 怎么把<li>标签里的内容付给文本框

    如果你不想使用jq,那就可以这样先写一个js函数,function val(a){alert(a);} 然后在li标签上添加点击事件,调用这个函数并将当前li里的文本当做参数一起发送给js函数< ...

  8. jQuery动态添加li标签并添加属性和绑定事件

    代码如下: <%@page import="java.util.ArrayList"%> <%@ page language="java" c ...

  9. 给奇数的li标签添加蓝色,给偶数的li标签添加红色

    今天遇到的面试题,哎,不看参考手册还是写的蛋疼啊!给奇数的li标签添加红色,给偶数的li标签添加蓝色 直接撸代码吧: <!DOCTYPE html> <html lang=" ...

随机推荐

  1. git - 必备指令

    1. 查看远程分支 加上-a参数可以查看远程分支,远程分支会用红色表示出来(如果你开了颜色支持的话): $ git branch -a master remote tungway v1. * zron ...

  2. python 开发webService

    最近在学习用python 开发webservice,费了半天时间把环境搭好,记录下具体过程,以备后用. 首先系统上要有python.其次要用python进行webservice开发,还需要一些库: 1 ...

  3. ParentChildTest.java

    public class ParentChildTest { public static void main(String[] args) { Parent parent=new Parent(); ...

  4. Spring+MyBatis实践—MyBatis数据库访问

    关于spring整合mybatis的工程配置,已经在Spring+MyBatis实践—工程配置中全部详细列出.在此,记录一下几种通过MyBatis访问数据库的方式. 通过sqlSessionTempl ...

  5. 在WIN32 DLL中使用MFC库遇到的问题

    今天写了一个DLL,DLL中用到的一个类里用到的MSXML的COM组件,所以在DLL中要包含afx.h头文件,也就不可避免的要用到MFC的类库了,但在编译时出现了错误:mfcs42d.lib(dllm ...

  6. 【转】深入研究java.lang.Runtime类

    一.概述      Runtime类封装了运行时的环境.每个 Java 应用程序都有一个 Runtime 类实例,使应用程序能够与其运行的环境相连接.      一般不能实例化一个Runtime对象, ...

  7. Centos系统备份与恢复教程

    Linux不像windows,它不限制根用户存取任何东西,因此,你完全可以把一个分区上每一个的文件放入一个TAR文件中. 使用root用户切换到根目录 然后,使用下面的命令备份完整的系统: tar c ...

  8. 220. Contains Duplicate III

    题目: Given an array of integers, find out whether there are two distinct indices i and j in the array ...

  9. 123. Best Time to Buy and Sell Stock III

    题目: Say you have an array for which the ith element is the price of a given stock on day i. Design a ...

  10. 12232 - Exclusive-OR

    12232 - Exclusive-OR 题目大意是可以设定一个点Xp=v,或者Xp^Xq=v,然后查询Xa^Xb^Xc...等于多少. 由于异或操作跟判连通性很类似,这里可以使用并查集来解决,对于X ...