在以下示例中,我尝试通过按notify.js API高级示例中建议的按钮来强制关闭打开的通知,该怎么办?
function CLOSE() {
$('#btn').trigger('notify-hide');
}
$(document).ready(function() {
$('#btn').notify('test note', {
position: 'right'
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/notify/0.4.2/notify.js"></script>
<button onClick="CLOSE()" id="btn" class="tst">Test</button>
您必须触发代表元素的notify-hide
事件。div
notify
function CLOSE() {
$('.notifyjs-wrapper').trigger('notify-hide');
}
$(document).ready(function() {
$('#btn').notify('test note', {
position: 'right'
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/notify/0.4.2/notify.js"></script>
<button onClick="CLOSE()" id="btn" class="tst">Test</button>
这是显示DOM结构外观的代码段:
<div class="notifyjs-wrapper notifyjs-hidable">
<div class="notifyjs-arrow" style="left: 41px; top: 6px; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-right: 5px solid rgb(238, 211, 215); display: none;">
</div>
<div class="notifyjs-container" style="left: 46px; top: -7.5px; display: none;">
<div class="notifyjs-bootstrap-base notifyjs-bootstrap-error">
<span data-notify-text="">test note</span>
</div>
</div>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句