在jquery扩展折叠中使用html

afdcj2ne  于 2022-11-29  发布在  jQuery
关注(0)|答案(2)|浏览(92)

我正在使用展开折叠在我的网站上使用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>
但是当我在全文中使用表时,它就停止工作了。请提出任何建议。

bqujaahr

bqujaahr1#

<p class="fulltext">改为<div class="fulltext">,它应该可以正常工作。在<p>中不能有其他块元素。

rjee0c15

rjee0c152#

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

相关问题