我有一個選擇,當我點擊選擇時,數據將出現在table id="tbl"
。隱藏p元素
我想在數據庫中不存在數據時隱藏表格,並使p標籤出現。但是,如果我這樣構造我的代碼,第二次點擊沒有價值的選項文本There is no record found did not appear
任何人都可以幫忙嗎?
function Report_response(data) {
console.log(data);
if (data.Elem1 != null) {
$('#elem1').html(data.Elem1);
$('#elem2').html(data.Elem2);
$('#elem3').html(data.Elem3);
$('#elem4').html(data.Elem4);
$('#tbl').css("display", "");
$('#noDataMsg').hide();
}
else {
$('#tbl').css("display", "none");
$('#noDataMsg').text("There is no record found");
}
我認爲這是因爲你不在'else'塊中顯示()'#noDataMsg'。 – Xufox