My question is the following, I have a Button and I want to change your text with the text of the li
(text of the <a>
tags) subsequent. At first I made a script that did not work, my intention in short, is to change the text of the button dropdown by the text of li
clicked.
HTML
<div class="btn-group col-xs-3 col-sm-3">
<button type="button" class="selectionCalendar btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Calendario <span class="caret"></span>
</button>
<ul class="selectionCalendar dropdown-menu box-white clearfix">
<li ><i class="fa fa-calendar" aria-hidden="true"></i><a href="#" class="WeekToday dropSelection">Hoje </a></li>
<li ><i class="fa fa-calendar" aria-hidden="true"></i><a href="#" class="CalendarWeek dropSelection">Semana </a></li>
<li ><i class="fa fa-calendar" aria-hidden="true"></i><a href="#" class="taskFullCalendar dropSelection"> Mês </a></li>
</ul>
</div>
Javascript
function trocatexto() {
let $dropChildren = $('.dropSelection');
let $option = $dropChildren.find('.dropSelection').text();
$('.dropSelection').click(function () {
$('.selectionCalendar').text($option);
});
}