我想設置新創建的元素在幾秒鐘後向上滑動。Jquery:如何在新創建的元素上設置延遲和向上滑動
$("div[data-error='true']").delay(5000).slideUp(500, function() {
$("#error-alert").remove();
});
$("div[data-success='true']").delay(5000).slideUp(500, function() {
$("#success-alert").remove();
});
例如,這些是將被動態地添加了元素:
<div class="alert alert-danger" role="alert" id="error-alert1" data-success="true">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
<span class="sr-only">Error:</span>
@ViewBag.Error
<button type="button" class="close" data-dismiss="alert">x</button>
</div>
<div class="alert alert-success" role="alert" id="success-alert1" data-error="true">
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
<span class="sr-only">Success:</span>
@ViewBag.Success
<button type="button" class="close" data-dismiss="alert">x</button>
</div>
如何設置動態創建的元件具有此效果基本show,延遲,如上所述移除事件?
另請包括您用於動態創建這些元素的代碼。 –