使用JQuery显示更多显示

我希望使用JQuery显示更多/更少.我通过谷歌搜索了几个例子,但都没有工作.没有什么花哨的,我只需要将一段文字剪切到特定的高度,并且链接将扩展/隐藏其他文本.

解决方法

这应该通过单击实际div来切换完整div的显示,您可以将click事件添加到您想要的任何触发器.

HTML:

<div id="blah">
    Long...Content
</div>

使用Javascript:

$('#blah').css({height:'20px',overflow:'hidden'});
$('#blah').on('click',function() {
    var $this = $(this);
    if ($this.data('open')) {
        $this.animate({height:'20px'});
        $this.data('open',0);

    }
    else {
        $this.animate({height:'100%'});
        $this.data('open',1);
    }
});

最初使用javascript显示较少不会无限期地为没有启用javascript的用户隐藏div.

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...