简体   繁体   中英

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:

<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?

There is no element on the page with the id extra-options. As a result,

$("#extra-options").is(':visible') always evaluates to false, and

$("#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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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