如果条件满足,我想在当前脚本显示div(gift)的同时显示工具提示:
if(total > 999 && total < 2999) { $('#gift-1').show();
同样适用于#gift-2:
if(total > 3000 && total < 4500) { $('#gift-2').show();
那时相应的工具提示应该可见:
#gift-1 = .tooltip-1
#gift-2 = .tooltip-2
这些应该只显示9秒钟,然后消失,直到#gift -1 or the div #gift-2再次显示div():
我尝试过类似的方法,但对我没有用:
if(total > 999 && total < 2999) { $('#gift-1').show();
$('.tooltip-1').fadeOut('slow');},9000);
我正在学习JS(新手,级别0),事实是我不知道该如何解决这个问题。
有任何想法吗...?
预先感谢!
// -------------
的HTML
<div class="tooltip-1"></div>
<div class="tooltip-2"></div>
<div id="gift-1"></div>
<div id="gift-2"></div>
的CSS
.tooltip-1,.tooltip-2 {display:none}
脚本
$(document).ready(function(){
function manageRegalo() {
var totalStorage = Number(localStorage.getItem("total"));
var total = Number($("#total").val().replace(".",""));
if(totalStorage != null && total === 0) {
total = totalStorage;
}
if(total > 999 && total < 2999) {
$('#gift-1').show();
}
else{
$('#gift-1').hide();
}
}
$(document).on('click', function (event) {
const target = event.target;
if (target.matches('.comp-clone') || target.matches('.bbp')) {
manageRegalo();
localStorage.setItem('total', Number($("#total").val().replace(".","")));
}
});
manageRegalo();
});
// -------------------------------------------------
$(document).ready(function(){
function manageRegaloDos() {
var totalStorage = Number(localStorage.getItem("total"));
var total = Number($("#total").val().replace(".",""));
if(totalStorage != null && total === 0) {
total = totalStorage;
}
if(total > 3000 && total < 4500) {
$('#gift-2').show();
}
else{
$('#gift-2').hide();
}
}
相关分类