For the icon button:
<button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> People <span class="caret"></span> </button>
I want to replace the text People and leave the html part of the button.
I have a situation that may require some flexibility. Perhaps I do not know the internal html of the button.
As a result, html will look something like this:
<button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> Jeff <span class="caret"></span> </button>
I am using jQuery, and if so, then:
$('button.dropdown-toggle').text('Jeff');
Obviously, this will remove the carriage. I do not want to remove the carriage.
I know that I can get the .children() doing .children() . But I will not necessarily know in what order the html element should be. Perhaps the carriage first, or maybe it was placed after the text, it can be in any order. What if there are two icons? I only want to replace the button text and leave html.
Usually I canβt control the HTML that will be in the button.
source share