JS控制ul之间上下移动 我使用ul实现了类似于层那种的数据列表效果,我现在想实现点击事件来改变成员的上下移动效果或者说如何用JS实现列表框成员的上下移动效果呢各位帮忙帮 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 +<SCRIPT>function fnSwap(){oList.children(0).swapNode(oList.children(1));}</SCRIPT><UL ID = oList><LI>List Item 1<LI>List Item 2<LI>List Item 3<LI>List Item 4</UL><INPUT TYPE = button VALUE = "Swap List" onclick = "fnSwap()"> 你这样只能实现前两个的交换,我如果想把List Item 1一直往下移动,直到和List Item 4交换呢 function swapNode(nodeD, nodeB) { if (nodeD.swapNode) { nodeD.swapNode(nodeB) } else { var E = nodeB.parentNode; var C = nodeB.nextSibling; if (C == nodeD) { E.insertBefore(nodeD, nodeB) } else { if (nodeB == nodeD.nextSibling) { E.insertBefore(nodeB, nodeD) } else { nodeD.parentNode.replaceChild(nodeB, nodeD); E.insertBefore(nodeD, C) } } }} <div class="bigCss"><ul id="Ul1" class="str"><li>书目列表1</li><li>书目列表2</li><li>书目列表3</li><li>书目列表4</li></ul><ul class="str" id="str1"><LI>List Item 1</LI><LI>List Item 1</LI><LI>List Item 1</LI><LI> 111</LI><LI> <img src="Images/1.gif" style="border:0px;" onclick="lastPage(1)" alt="上移"/><img src="Images/2.gif" style="border:0px;" onclick="nextPage(1)" alt="下移"/></LI></UL><UL class="str" id="str2"><LI>List Item 2</LI><LI>List Item 2</LI><LI>List Item 2</LI><LI>222</LI><LI><img src="Images/1.gif" style="border:0px;" onclick="lastPage(2)" alt="上移"/><img src="Images/2.gif" style="border:0px;" onclick="nextPage(2)" alt="下移"/></LI></UL><UL class="str" id="str3"><LI>List Item 3</LI><LI>List Item 3</LI><LI>List Item 3</LI><LI>333</LI><LI><img src="Images/1.gif" style="border:0px;" onclick="lastPage(3)" alt="上移"/><img src="Images/2.gif" style="border:0px;" onclick="nextPage(3)" alt="下移"/></LI></UL><UL class="str" id="str4"><LI>List Item 4</LI><LI>List Item 4</LI><LI>List Item 4</LI><LI>4444</LI><LI><img src="Images/1.gif" style="border:0px;" onclick="lastPage(4)" alt="上移"/><img src="Images/2.gif" style="border:0px;" onclick="nextPage(4)" alt="下移"/></LI></UL><UL class="str" id="str5"><LI>List Item 5</LI><LI>List Item 5</LI><LI>List Item 5</LI><LI>5555</LI><LI><img src="Images/1.gif" style="border:0px;" onclick="lastPage(5)" alt="上移"/><img src="Images/2.gif" style="border:0px;" onclick="nextPage(5)" alt="下移"/></LI></UL><UL class="str" id="str6"><LI>List Item 6</LI><LI>List Item 6</LI><LI>List Item 6</LI><LI>666</LI><LI> <img src="Images/1.gif" style="border:0px;" onclick="lastPage(6)" alt="上移"/><img src="Images/2.gif" style="border:0px;" onclick="nextPage(6)" alt="下移"/></LI></UL></div> <!----调用脚本-----> <script type="text/javascript" src="JS/jquery-1.3.min.js"></script> <script type="text/javascript"> function nextPage(page) { var temp; var last1="#str"+page; var next2="#str"+(parseInt(page)+1); if($(last1).children("li").length+1==page) { alert("数据已移至末尾"); } else { if($(last1).children("li").length==$(next2).children("li").length) { for(var j=0;j<$(last1).children("li").length-1;j++) { temp=$(last1).children("li").eq(j).html(); $(last1).children("li").eq(j).html($(next2).children("li").eq(j).html()); $(next2).children("li").eq(j).html(temp); } } } } function lastPage(page) { var temp; var last1="#str"+page; var next2="#str"+(parseInt(page)-1); if(page==1) { alert("数据已移至首部"); } else { if($(last1).children("li").length==$(next2).children("li").length) { for(var j=0;j<$(last1).children("li").length-1;j++) { temp=$(last1).children("li").eq(j).html(); $(last1).children("li").eq(j).html($(next2).children("li").eq(j).html()); $(next2).children("li").eq(j).html(temp); } } } } </script> 关于日历控件问题 这句话应该怎么理解? js幻灯片功能更改!鼠标指向数字,自动变到相应图片 关于SyntaxError: unterminated string literal的问题 <script defer="defer">这句在FIREFOX下怎样实现? 有关_self和opener的问题 省份及市区相关的二极下拉菜单 SCRIPT.EatMemory病毒,应该如何清除呢? 请教:如何用javascript写空格? 如何通过判断关联两个数组并渲染 QQ网上的轮显代码,抠下来了,运行没问题,放到表格框中就不动了,求解?在线等,谢谢 提示框如何实现
function fnSwap(){
oList.children(0).swapNode(oList.children(1));
}
</SCRIPT>
<UL ID = oList>
<LI>List Item 1
<LI>List Item 2
<LI>List Item 3
<LI>List Item 4
</UL>
<INPUT TYPE = button VALUE = "Swap List" onclick = "fnSwap()">
你这样只能实现前两个的交换,我如果想把List Item 1一直往下移动,直到和List Item 4交换呢
function swapNode(nodeD, nodeB) {
if (nodeD.swapNode) {
nodeD.swapNode(nodeB)
} else {
var E = nodeB.parentNode;
var C = nodeB.nextSibling;
if (C == nodeD) {
E.insertBefore(nodeD, nodeB)
} else {
if (nodeB == nodeD.nextSibling) {
E.insertBefore(nodeB, nodeD)
} else {
nodeD.parentNode.replaceChild(nodeB, nodeD);
E.insertBefore(nodeD, C)
}
}
}
}
<ul id="Ul1" class="str">
<li>书目列表1</li>
<li>书目列表2</li>
<li>书目列表3</li>
<li>书目列表4</li>
</ul>
<ul class="str" id="str1">
<LI>List Item 1</LI>
<LI>List Item 1</LI>
<LI>List Item 1</LI>
<LI>
111
</LI>
<LI> <img src="Images/1.gif" style="border:0px;" onclick="lastPage(1)" alt="上移"/>
<img src="Images/2.gif" style="border:0px;" onclick="nextPage(1)" alt="下移"/></LI>
</UL>
<UL class="str" id="str2">
<LI>List Item 2</LI>
<LI>List Item 2</LI>
<LI>List Item 2</LI>
<LI>222
</LI>
<LI>
<img src="Images/1.gif" style="border:0px;" onclick="lastPage(2)" alt="上移"/>
<img src="Images/2.gif" style="border:0px;" onclick="nextPage(2)" alt="下移"/>
</LI>
</UL>
<UL class="str" id="str3">
<LI>List Item 3</LI>
<LI>List Item 3</LI>
<LI>List Item 3</LI>
<LI>333</LI>
<LI>
<img src="Images/1.gif" style="border:0px;" onclick="lastPage(3)" alt="上移"/>
<img src="Images/2.gif" style="border:0px;" onclick="nextPage(3)" alt="下移"/>
</LI>
</UL>
<UL class="str" id="str4">
<LI>List Item 4</LI>
<LI>List Item 4</LI>
<LI>List Item 4</LI>
<LI>4444</LI>
<LI>
<img src="Images/1.gif" style="border:0px;" onclick="lastPage(4)" alt="上移"/>
<img src="Images/2.gif" style="border:0px;" onclick="nextPage(4)" alt="下移"/>
</LI>
</UL>
<UL class="str" id="str5">
<LI>List Item 5</LI>
<LI>List Item 5</LI>
<LI>List Item 5</LI>
<LI>5555</LI>
<LI><img src="Images/1.gif" style="border:0px;" onclick="lastPage(5)" alt="上移"/>
<img src="Images/2.gif" style="border:0px;" onclick="nextPage(5)" alt="下移"/></LI>
</UL>
<UL class="str" id="str6">
<LI>List Item 6</LI>
<LI>List Item 6</LI>
<LI>List Item 6</LI>
<LI>666</LI>
<LI>
<img src="Images/1.gif" style="border:0px;" onclick="lastPage(6)" alt="上移"/>
<img src="Images/2.gif" style="border:0px;" onclick="nextPage(6)" alt="下移"/>
</LI>
</UL></div> <!----调用脚本----->
<script type="text/javascript" src="JS/jquery-1.3.min.js"></script>
<script type="text/javascript">
function nextPage(page)
{
var temp;
var last1="#str"+page;
var next2="#str"+(parseInt(page)+1);
if($(last1).children("li").length+1==page)
{
alert("数据已移至末尾");
}
else
{
if($(last1).children("li").length==$(next2).children("li").length)
{
for(var j=0;j<$(last1).children("li").length-1;j++)
{
temp=$(last1).children("li").eq(j).html();
$(last1).children("li").eq(j).html($(next2).children("li").eq(j).html());
$(next2).children("li").eq(j).html(temp);
}
}
}
}
function lastPage(page)
{
var temp;
var last1="#str"+page;
var next2="#str"+(parseInt(page)-1);
if(page==1)
{
alert("数据已移至首部");
}
else
{
if($(last1).children("li").length==$(next2).children("li").length)
{
for(var j=0;j<$(last1).children("li").length-1;j++)
{
temp=$(last1).children("li").eq(j).html();
$(last1).children("li").eq(j).html($(next2).children("li").eq(j).html());
$(next2).children("li").eq(j).html(temp);
}
}
}
}
</script>