That works fine, but some of the buttons that will fall under this function will say “Learn More” instead of “Read More”, so I was trying to figure out a way to have the jquery only change the word instead of updating the phrase.
So, if “More” is there, change that to “Less”, and back and forth.
Normally you wouldn’t parse and replace text like this in your JS – that will get messy pretty quickly, especially if you add multi language support at some point. You might handle this with a class though:
Actually, I forgot why I was using Javascript. This is a great solution, if the button could be edited (the code), but I am writing a script that converts the WPBakery template buttons for Wordpress. So you can only add one amount of “text” into the button with WPBakery. Now, you could do a text block instead and copy/paste the typical button code and then edit it manually. But plugin and theme updates might present somewhat of an issue.