man5 Posted March 3, 2015 Share Posted March 3, 2015 Say I have button 1 and I want to replace it with button2 on click. How would I do that? <button id="button1">butto 1</button> <button id="button2">butto 2</button> Link to comment https://forums.phpfreaks.com/topic/295037-is-it-possible-to-replace-a-div-or-button-on-click/ Share on other sites More sharing options...
Stefany93 Posted March 3, 2015 Share Posted March 3, 2015 How exactly do you want to replace it? You want to put the value from the one button to the other, or...? Link to comment https://forums.phpfreaks.com/topic/295037-is-it-possible-to-replace-a-div-or-button-on-click/#findComment-1507341 Share on other sites More sharing options...
jeffreyappel Posted March 6, 2015 Share Posted March 6, 2015 I have an alternate way: <!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <style> </style> </head> <body> <button class="button1">button 1</button> <button class="button2">button 2</button> <script> $(document).ready(function(){ $(".button1").click(function(){ $(".button1").hide(); $(".button2").show(); }); $(".button2").click(function(){ $(".button2").hide(); $(".button1").show(); }); }); </script> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/295037-is-it-possible-to-replace-a-div-or-button-on-click/#findComment-1507761 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.