[英]How to undo $( “button” ).remove()?
I am using JQuery's 我正在使用JQuery
$( ".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. 用户单击打印PDF按钮后立即从我的页面上删除所有按钮的方法,该按钮会将HTML页面转换为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 当您希望他们回来时,说您想在单击pdf按钮后将它们退回,所以在此子句中
$(".button").show();
You can use the display
functionality in css, that is in your css 您可以在CSS中使用display
功能,即在CSS中
.button {
display:inline;
}
In your javascript, I see you using jQuery, you just change this: To remove: 在您的JavaScript中,我看到您使用jQuery,您只需更改以下内容即可:要删除:
$('.button').css('display', 'none');
To return back: 返回:
$('.button').css('display', 'inline');
You can trigger for all button with a button. 您可以使用按钮触发所有按钮。 Try toggle
function. 尝试toggle
功能。
$(".toggleButton").click(function(){
$(".button").toggle();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.