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

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Restarting Supervisor and effect on FlaskSocketIO -

php - Mongodb connectivity error -