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

推荐订阅源

Recent Announcements
Recent Announcements
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
aimingoo的专栏
aimingoo的专栏
I
InfoQ
B
Blog
WordPress大学
WordPress大学
Jina AI
Jina AI
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园_首页
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
酷 壳 – CoolShell
酷 壳 – CoolShell
阮一峰的网络日志
阮一峰的网络日志
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
Google Developers Blog
C
Check Point Blog
月光博客
月光博客
L
LangChain Blog
GbyAI
GbyAI

博客园 - .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>