在jquery中使用html展开折叠

时间:2013-07-18 11:26:05

标签: jquery expand collapse

我使用jquery和html代码在我的网站上使用展开折叠:

<script>
$(document).ready(function () {
    $('.fulltext').hide();

    $('.blog-item .readmore').click(function (event) {
        event.preventDefault();
        $(this).parent().find('.fulltext').slideToggle('slow');
        $(this).text($(this).text() == 'Close Deals' ? 'More Deals' : 'Close Deals');
    });
});
</script>

HTML:

<div class="blog-item">
        <p class='fulltext'>Read more text will be here.</p>
    <a class="readmore" href="#">Read more..</a>
</div>

实际上我想在隐藏文本中使用表格,现在是:<p class='fulltext'>Read more text will be here.</p>

但是当我在fulltext中使用table时它停止工作。请任何建议。

2 个答案:

答案 0 :(得分:1)

<p class="fulltext">更改为<div class="fulltext">,它应该可以正常工作。您不能在<p>

中包含其他块元素

答案 1 :(得分:0)

<div>元素用于描述数据容器,而<p>元素用于描述内容段落。要使用内部使用div标记的表格。

Fiddle