0

我刚刚实现了here的基本隐藏和显示。

这是一个工作示例代码:

<div id="content" class="collapse" >
//Place content in here
</div>
<a href="content" data-toggle="collapse" style="cursor:pointer;">Read More</a>

我的下一个任务是在单击事件上将“阅读更多”更改为“阅读更少”。

问题是如何检查正在发生的事件以及如何使用它。

示例 Twitter 代码

$('#myCollapsible').on('hidden', function () {
    // do something…
    })

我不明白的部分是什么是“#myCollapsible”?那会是缩小的 div id 吗?

4

2 回答 2

0

使用它是正确的

$('#content')

而不是使用

$('#myCollapsible')

在你的情况下:)

于 2012-08-08T19:33:20.763 回答
0

一个完整的解决方案是:

$( '#content' ).on( 'hidden', function() {
    $( 'a[href="' + this.id + '"]' ).html( 'Read More' );
}).on( 'shown', function() {
    $( 'a[href="' + this.id + '"]' ).html( 'Read Less' );
});

如果你想要一些通用的东西,你可以$( '#content' )$( '.collapse' ).

于 2012-08-08T19:38:10.623 回答