简体   繁体   中英

How to undo $( “button” ).remove()?

I am using JQuery's

$( ".button" ).remove();

method to remove all buttons from my page on right after user clicks print PDF button which converts the HTML Page to PDF. However, after that operation is complete I want the button to be inserted again without refreshing the page. Is there a way to do this?

if you want it back you dont need to remove them but hiding them will be better.

$(".button").hide();

when you want them back say you wanna have them back after the pdf button clicked so in this clause

$(".button").show();

You can use the display functionality in css, that is in your css

.button {
   display:inline;
}

In your javascript, I see you using jQuery, you just change this: To remove:

$('.button').css('display', 'none');

To return back:

$('.button').css('display', 'inline');

You can trigger for all button with a button. Try toggle function.

   $(".toggleButton").click(function(){
        $(".button").toggle();
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM