简体   繁体   English

为什么此按钮中的文本不回退?

[英]Why is the text in this button not toggling back?

I'll try and make it easier to help on this one. 我会尽力使这一方面的工作变得更容易。

Here is the HTML: 这是HTML:

<button class="btn" id="follow-button"><i class="fa fa-twitter" aria-hidden="true"></i> Follow
  </button>

I want the button to change from saying "Follow" to "Following" when clicked. 我希望按钮在单击时从说“关注”变为“关注”。 And when you click it while it says "Following" I want it to switch to "Follow". 当您单击显示为“正在关注”时,我希望它切换为“正在关注”。

How is this approached with JS? JS如何处理?

There is no element on the page with the id extra-options. 该页面上没有包含id extra-options的元素。 As a result, 结果是,

$("#extra-options").is(':visible') always evaluates to false, and $("#extra-options").is(':visible')始终为false,并且

$("#extra-options").Toggle(); always throws an error. 总是抛出一个错误。

EDIT: as @phil points out in the comments, the Jquery toggle function is spelled with a lower case t 编辑:@phil在注释中指出,Jquery toggle功能的拼写是小写的t

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM