js
(function($) {
// public plugins
var children;
var opts;
$.fn.lessmore = function(options) {
// 函数私有变量
opts = $.extend($.fn.lessmore.defaults, options || {});
return this.each(function() {
var $this = $(this);
children = $this.children().filter('div');
var totle = children.length;
children.slice(opts.length).hide();
// $(children[opts.length]).before('<span>more</span>');
addmore();
return $this;
});
};
var addmore = function() {
$('<span class="more">'+opts.moreText+'</span>').insertAfter($(children[opts.length])).click(
function() {
children.slice(opts.length).show();
$(this).hide();
addless();
});
};
var addless = function() {
$('<span class="less">'+opts.lessText+'</span>').insertAfter($(children[children.length - 1]))
.click(function() {
children.slice(opts.length).hide();
$(this).hide();
addmore();
});
};
// default parameters
$.fn.lessmore.defaults = {
length : 3,
lessText : '[less]',
moreText : '[more]'
};
})(jQuery);
html
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css" media="all">
.more, .less {
text-decoration:underline;
color:#003399;
cursor:hand;}
</style>
<script type="text/javascript" src="lib/jquery-1.2.6.js"></script>
<script type="text/javascript" src="lib/scripts/3p/test3.js"></script>
<title>无标题文档</title>
<script type="text/javascript">
$(function(){
$('#content').lessmore();
});
</script>
</head>
<body>
<h1>jquery.lessMore</h1>
<div id="content">
<div> item 1 </div>
<div> item 2 </div>
<div> item 3 </div>
<div> item 4 </div>
<div> item 5 </div>
<div> item 6 </div>
<div> item 7 </div>
<div> item 8 </div>
<div> item 9 </div>
<div> item 10 </div>
<div> item 11 </div>
<div> item 12 </div>
</div>
</body>
</html>
效果:
- 大小: 1.7 KB
- 大小: 2.7 KB
分享到:
- 2009-01-21 09:47
- 浏览 1251
- 评论(0)
- 论坛回复 / 浏览 (0 / 1673)
- 查看更多
相关推荐
jQueryAPI-090129.rar jQueryAPI-090129文档 jQueryAPI-090129参考文档 jQueryAPI文档,参考文档
jquery-3.3.1.js和jquery-3.3.1.min.js免费下载哈。jquery-3.3.1.js和jquery-3.3.1.min.js免费下载哈。jquery-3.3.1.js和jquery-3.3.1.min.js免费下载哈。jquery-3.3.1.js和jquery-3.3.1.min.js免费下载哈。jquery-...
开发工具 jquery-1.11.3.min开发工具 jquery-1.11.3.min开发工具 jquery-1.11.3.min开发工具 jquery-1.11.3.min开发工具 jquery-1.11.3.min开发工具 jquery-1.11.3.min开发工具 jquery-1.11.3.min开发工具 jquery-...
jquery-uijquery-uijquery-uijquery-uijquery-uijquery-uijquery-uijquery-uijquery-uijquery-uijquery-uijquery-uijquery-uijquery-uijquery-uijquery-ui
jquery-3.7.0.min.js(jQuery下载)jquery-3.7.0.min.js(jQuery下载)jquery-3.7.0.min.js(jQuery下载)jquery-3.7.0.min.js(jQuery下载)jquery-3.7.0.min.js(jQuery下载)jquery-3.7.0.min.js(jQuery下载)...
jquery插件jquery-ui-1.8.18.custom.min.js
jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-...
jquery-1.3.2-vsdoc.js jquery-1.8.3.min.js jquery-1.3.2.min.js jquery-1.4.1-vsdoc.js jquery-1.4.1.min.js jquery-1.4.2-vsdoc.js jquery-1.4.2.min.js jquery-1.4.3-vsdoc.js jquery-1.4.3.min.js ...
这里包含jquery-ui-1.8.16.custom.min.js/jquery-ui-1.8.16.custom.css,我费了好长时间找到的,此东西可以配合jQuery UI开发指南一书使用。
${ctx}/plugins/jquery-ui-1.11.2/jquery-ui.css" > ${ctx}/plugins/jquery-ui-1.11.2/external/jquery/jquery.js"> ${ctx}/plugins/jquery-ui-1.11.2/jquery-ui.js"> ${ctx}/plugins/jquery-ui-1.11.2/jquery-ui-...
jquery-ui-1.8.2.custom.min.js,jquery-ui-1.8.4.custom.css
压缩包内包含jquery-1.6.4.js jquery-1.6.4.min.js jquery-1.6.4-vsdoc.js 。 【推荐用法】 1、将jquery-1.6.4-vsdoc.js与jquery-1.6.4.js放在同一目录,然后在vs中添加对jquery-1.6.4.js的引用即可; 2、切记:...
jquery-easyui-EDT-1.5.2-build1 jquery-easyui-EDT-1.5.2-build1
jquery-ui-日期框扩展成时间框 jquery-ui时间框 基于别人的代码进行修改 jquery-ui-1.8.16.custom.css文件末尾加入以下代码 .ui-timepicker-div .ui-widget-header{ margin-bottom: 8px; } .ui-timepicker-div dl{ ...
jquery-ui-1.8.18.custom
jquery--frame--ziyuan jquery--frame--ziyuan jquery--frame--ziyuan jquery--frame--ziyuan
jQuery版本迁移辅助插件,如果您使用的低版本jQuery改为高版本后出现错误,可以试试这个插件。用来检测和恢复在jQuery1.9版本中已删除或已过时的API。jquery-migrate-1.2.1.js,jquery-migrate-1.2.1.min.js
jquery-1.11.0 + jquery-UI-1.10.4
jquery-ui-1.9.2.custom.min.js
jQuery jQuery-UI