[英]Hide button after click
I'm trying to hide the button after it has been clicked. 我试图在单击按钮后隐藏该按钮。 Once the button is clicked, there is no use for it so I would like to hide it , but keep the confirmation message
单击按钮后,就没有用了,因此我想将其隐藏,但保留确认消息
Here's the existing code that does everything properly (except hide the button after the click): 这是可以正确执行所有操作的现有代码(单击后隐藏按钮除外):
<a class="btn btn-danger _btn_" onclick="save()">Register button</a>
<div id="confirmation"></div>
function save() {
var number_i = $('#number_i').text();
var date_s = $('#date_s').text();
var name_p = "<?php echo $_POST['product_name']; ?>";
if (number_i != '___') {
$.post('saveEntry.php', {number: number_i, date: date_s, name: name_p}, function() {
$('#confirmation').text('Info: the data was saved!');
$('#confirmation').attr('class', 'alert alert-success');
})
} else {
alert('Introdu Numar Bon Fiscal!');
}
};
在点击事件内部使用以下代码。
$(this).css('display', 'none');
Did you try: 你试过了吗:
$('._btn_').hide();
or perhaps adding an id to it: 或添加一个ID:
<a class="btn btn-danger _btn_" id="button-to-hide" onclick="save()">Register button</a>
...
$('#button-to-hide').hide();
将此添加到您的保存功能
$(this).hide();
please try this code 请尝试此代码
<a class="btn btn-danger _btn_" onclick="save()">Register button</a>
<div id="confirmation"></div>
function save() {
$('.btn-danger').hide()
var number_i = $('#number_i').text();
var date_s = $('#date_s').text();
var name_p = "<?php echo $_POST['product_name']; ?>";
if (number_i != '___') {
$.post('saveEntry.php', {number: number_i, date: date_s, name: name_p}, function() {
$('#confirmation').text('Info: the data was saved!');
$('#confirmation').attr('class', 'alert alert-success');
})
} else {
alert('Introdu Numar Bon Fiscal!');
}
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.