美文网首页
阅读更多

阅读更多

作者: zjyxjtu | 来源:发表于2017-12-01 13:58 被阅读0次
<div id="wrap{{ subject.id }}" class="wrap">{{ subject.about_subject | safe }}</div>
<div id="read-more{{ subject.id }}" class="read-more"></div>
<style>
.wrap{position: relative;overflow: hidden;}
.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">
{% for subject in subjects %}
$(function(){
 var slideHeight = 300; // px
 var defHeight = $('#wrap{{ subject.id }}').height();
 if(defHeight >= slideHeight){
  $('#wrap{{ subject.id }}').css('height' , slideHeight + 'px');
  $('#read-more{{ subject.id }}').append('<a href="#">查看更多</a>');
  $('#read-more{{ subject.id }} a').click(function(){
   var curHeight = $('#wrap{{ subject.id }}').height();
   if(curHeight == slideHeight){
    $('#wrap{{ subject.id }}').animate({
     height: defHeight
    }, "normal");
    $('#read-more{{ subject.id }} a').html('隐藏');
   }else{
    $('#wrap{{ subject.id }}').animate({
     height: slideHeight
    }, "normal");
    $('#read-more{{ subject.id }} a').html('查看更多');
   }
   return false;
  });
 }
});
{% endfor %}
</script>

相关文章

网友评论

      本文标题:阅读更多

      本文链接:https://www.haomeiwen.com/subject/lvbbbxtx.html