本文介绍了在点击时链接文字更改。查看更多,查看更少jquery - Bootstrap手风琴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我用 bootstrap 手风琴隐藏/取消隐藏信息。

So I've used bootstrap accordion to hide/unhide info.

我需要改变从看得更多到看不到。

I needed the wording to change from 'See more' to 'See less' continuously.

我实现了这一点,您可以在

I've implemented this as you can see in the bootply

正如你将看到的,我面临的问题是,当第一次点击它从'查看更多'到'查看更多',然后再次点击它开始工作,因为我想要它。

As you will see, the problem I'm facing is that when first clicked it moves from 'See more' to 'See more' then click again it starts working as I want it to.

我知道为什么会发生,但是我不知道如何删除href文本并立即显示隐藏的信息。

I know why its happening but cant figure out how I can remove the a href text and show the hidden info straight away.

$(document).ready(function () {
    $("#morebtn").click(function () {
        $(this).html($(this).html() == "See more" ? "See less" : "See more");
    });
});


推荐答案

c $ c>< strong>按您的想法查看更多< / strong> 不是查看更多。

将其更改为 $ .text()==查看更多并且它的工作原理:)

然后你可以只添加一个类到元素,使其粗体。否则,您每次都需要使用< strong> 标记重新打包

It's because first time round your HTML is actually <strong>See more</strong> not "See more" as you think.
Change it to $(this).text() == "See more" and it works :)
You can then just add a class to the element to make it bold. Otherwise you'll need to re-wrap with the <strong> tag each time

这篇关于在点击时链接文字更改。查看更多,查看更少jquery - Bootstrap手风琴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 13:09