惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recent Announcements
Recent Announcements
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
T
The Blog of Author Tim Ferriss
J
Java Code Geeks
腾讯CDC
D
Docker
G
Google Developers Blog
D
DataBreaches.Net
雷峰网
雷峰网
Blog — PlanetScale
Blog — PlanetScale
S
SegmentFault 最新的问题
The Cloudflare Blog
有赞技术团队
有赞技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Stack Overflow Blog
Stack Overflow Blog
大猫的无限游戏
大猫的无限游戏
量子位
美团技术团队
aimingoo的专栏
aimingoo的专栏
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Engineering at Meta
Engineering at Meta
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - .net小鸟

产品很重要 JQUERY FAQ 无法打开到主机的连接,在端口xxx连接失败 eclipse的调试技术 js parseInt与排序 html到asp.net样式变乱 django学习资料 FAQ js工具类 python31操作MySql jquery iframe 父子互操作 .net连接mysql maven下载地址 notepad++中用正则表达式 jquery 两个控件同享一个function javascript 经常会用到的东西 javascript template javascript closure anonymous function javafirststep
jquery操作ul
.net小鸟 · 2011-07-28 · via 博客园 - .net小鸟

View Code

<html>
<head>
<script type="text/javascript" src="jquery-1.6.2.min.js"></script>
<script>
function exchangePosition()
{
    
//alert($("#list>li").size());
    //alert($("#list>li").length);
    //alert($("#li1").insertAfter($("#li2")));
    alert($("#li3").insertBefore($("#li2")))
    
//alert($("#li1").before().html());
    alert($("#li3").index());
    
var len = $("#ul>li").length;
    
    
    $(
"#list").children("li").eq(0).css("background-color","red");
    $(
"#list").children("li").eq(len-1).css("background-color","green");    
}

window.onload 

= function(){
    exchangePosition();
}
</script></head>
<body>
<ul id="list">
<li id="li1">11</li>
<li id="li2">22</li>
<li id="li3">33</li>
</ul>
</body>
</html>