javascript - replace button text with .replaceWith() -
this not seeming work me jsfiddle
$(document).ready(function() { $('.dropdown-menu>li>a').on("click", function() { var buttontext = $(this).text(); $('.dropdown-toggle').replacewith(buttontext); }); });
try following:
$(document).ready(function() { $('.dropdown-menu > li > a').on("click", function() { var buttontext = $(this).text(); $('.dropdown-toggle').text(buttontext); }); }); your query selector incorrectly using dropdown instead of dropdown-menu. also, replacewith() replace entire element, it's best use .text() change inner text of button.
Comments
Post a Comment