最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

jquery实现点击查看更多内容控制段落文字展开折叠效果_jquery

来源:动视网 责编:小采 时间:2020-11-27 21:41:38
文档

jquery实现点击查看更多内容控制段落文字展开折叠效果_jquery

jquery实现点击查看更多内容控制段落文字展开折叠效果_jquery:本文实例讲述了jquery实现点击查看更多内容控制段落文字展开折叠效果。分享给大家供大家参考。具体如下:这里使用jQuery实现的文字展开折叠效果,点击文字后文字内容会完整的显示出来,控制段落来显示文字,不需要的时候,可以再次点击后将内容折叠起来,也就
推荐度:
导读jquery实现点击查看更多内容控制段落文字展开折叠效果_jquery:本文实例讲述了jquery实现点击查看更多内容控制段落文字展开折叠效果。分享给大家供大家参考。具体如下:这里使用jQuery实现的文字展开折叠效果,点击文字后文字内容会完整的显示出来,控制段落来显示文字,不需要的时候,可以再次点击后将内容折叠起来,也就
 本文实例讲述了jquery实现点击查看更多内容控制段落文字展开折叠效果。分享给大家供大家参考。具体如下:

这里使用jQuery实现的文字展开折叠效果,点击文字后文字内容会完整的显示出来,控制段落来显示文字,不需要的时候,可以再次点击后将内容折叠起来,也就是隐藏了一部分内容。点击查看更多的功能,在很多大网站都有在用,像一些电影简介、产品介绍有时候为了页面的布局效果,常常默认是隐藏了一部分,用户想看的时候可以点击后展开。

运行效果如下图所示:

具体代码如下:

<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery文本段落展开和折叠效果</title>
<style>
html,body,p,h2,p{margin: 0;padding: 0;}
html{font: 1em Arial, Helvetica, sans-serif;color: #444;}
a{color: #0087f1;}
p{margin-bottom: 5px;}
#container{margin: 0 auto;width: 600px;}
#container h2{font-size: 20px;color: #0087f1;}
#wrap{position: relative;padding: 10px;overflow: hidden;}
#gradient{width: 100%;height: 35px;background: url() repeat-x;position: absolute;bottom: 0;left: 0;}
#read-more{padding: 5px;border-top: 4px double #ddd;background: #fff;color: #333;}
#read-more a{padding-right: 22px;background: url() no-repeat 100% 50%;font-weight: bold;text-decoration: none;}
#read-more a: hover{color: #000;}
</style>
<script type="text/javascript" src="jquery-1.6.2.min.js?7.1.34"></script>
<script type="text/javascript">
$(function(){
 var slideHeight = 75; // px
 var defHeight = $('#wrap').height();
 if(defHeight >= slideHeight){
 $('#wrap').css('height' , slideHeight + 'px');
 $('#read-more').append('<a href="#">点击查看更多。</a>');
 $('#read-more a').click(function(){
 var curHeight = $('#wrap').height();
 if(curHeight == slideHeight){
 $('#wrap').animate({
 height: defHeight
 }, "normal");
 $('#read-more a').html('点击隐藏');
 $('#gradient').fadeOut();
 }else{
 $('#wrap').animate({
 height: slideHeight
 }, "normal");
 $('#read-more a').html('点击查看更多。');
 $('#gradient').fadeIn();
 }
 return false;
 }); 
 }
});
</script>
</head>
<body>
 <p id="container">
 <h1>jQuery 控制段落文字展开折叠,点击查看更多的功能</h1>
 <h2>About Billabong</h2>
 <p id="wrap">
 <p>
 <p>Gordon developed his own stitching technique, which made the garments more durable, cost effective and less labor intensive. He employed machinists, moved the operation into a factory, set up a distribution network and sponsored a team of renowned Australian surfers. The business thrived.</p>
 <p>Since those beginnings, Billabong has expanded its product range to include boardsport products such as wetsuits, watches, surfboards, snowboard outerwear and skateboarding apparel.</p>
 </p>
 <p id="gradient"></p>
 </p>
 <p id="read-more"></p>
 </p>
</body>
</html>

文档

jquery实现点击查看更多内容控制段落文字展开折叠效果_jquery

jquery实现点击查看更多内容控制段落文字展开折叠效果_jquery:本文实例讲述了jquery实现点击查看更多内容控制段落文字展开折叠效果。分享给大家供大家参考。具体如下:这里使用jQuery实现的文字展开折叠效果,点击文字后文字内容会完整的显示出来,控制段落来显示文字,不需要的时候,可以再次点击后将内容折叠起来,也就
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top