我有一套PHP通知系统,通知的数量将用 j子输入DIV。 唯一的问题是,当有0份通知时,空洞的DIV仍然显示出来。 这是我目前正在使用的 j:
$(document).ready(function() {
$.get( /codes/php/nf.php , function(a) {
$( #nfbadge ).html(a);
$( #nfbadge:empty ).remove();
})
});
setInterval(function() {
$.get( http://localhost/codes/php/nf.php , function(a) {
$( #nfbadge ).html(a);
$( #nfbadge:empty ).remove();
})
}, 8000);
The only problem is that if at document load there is 0 notifications and a notification is added, the badge will not show up, so basically if the element is removed it won t come back unless the page is reloaded, but I made the notification system so that the page wouldn t have to be reloaded. How can I fix this?