I have a button that toggles a div to expand and minimize.
The button looks like this:
<a id="map-toggle" href="#"><i class="icon map-arrow-icon closed"></i>Expand Map</a>
I would like to be able to toggle the "Expand Map" to "Minimize Map" when it is clicked and have something like the following in my click handler.
$(this).text( function(i, text) {
return text === 'Expand Map' ? text.replace('Expand', 'Minimize') : text.replace('Minimize', 'Expand');
});
This works good, excecpt that is strips out the icon "<i class="icon map-arrow-icon closed"></i>".
How can I do that without removing the icon when this button is clicked.
Thanks a lot for any help!