I currently have an onclick event that switches classes like this:
.... <button id="@m.TargetCo.ButtonId" onclick="glyphChanger(this.id)" class="btn btn-default iconButton glyphicon glyphicon-chevron-right" ></button> .... function glyphChanger(buttonID) { $("#" + buttonID).toggleClass('glyphicon-chevron-right glyphicon-chevron-up'); }
P粉2698479972024-03-28 00:03:54
No JavaScript required. You can do this the Blazor way.
DropDownComponent.razor
Debug: @buttonCss
@code { private string buttonCss = "glyphicon-chevron-right"; private void ChangeButtonClass() { buttonCss = buttonCss == "glyphicon-chevron-right" ? "glyphicon-chevron-up" : "glyphicon-chevron-right"; } }
Elsewhere in the app