首页 > 开发 > Javascript > 正文

基于jquery的超简单上下翻

2020-02-28 04:08:31
字体:
来源:转载
供稿:网友
代码如下:
<html>
<head>
<title>超简单上下翻</title>
<script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>
简单上下翻,函数
<script type="text/javascript">
function UpDown(What) {
var aList = $("#tab a");
var oldnode = aList.get(0);
/*
*获取最后一个元素三种方法
*/
newnode = aList[aList.length - 1];
newnode = aList.get(aList.length - 1);
newnode = $("#tab a:last");
if (What == "up") return $(oldnode).before(newnode);
$(newnode).after(oldnode)
}
</script>
<div id="tab">
<a href='#'> a </a><a href='#'> b </a><a href='#'> c </a><a href='#'> d </a><a href='#'> e </a><a href='#'> f </a></div>
<a href='#' onclick="UpDown('up')">上一个</a>
<a href='#' onclick="UpDown()">下一个</a>
</body>
</html>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表