Use this way:
function AlertSave() {
$("#infor").fadeIn("slow", function () {
setTimeout(function () {
$("#infor").fadeOut("slow");
}, 1000);
});
}
Fiddle: http://jsfiddle.net/0zdLbqa7/
You can also use the shorthand:
$("#infor").fadeIn("slow").delay(1000).fadeOut("slow");
Snippets for Both:
$(document).ready(function () {
$("#infor").hide();
$("#btnSave").click(AlertSave);
});
function AlertSave() {
$("#infor").fadeIn("slow", function () {
setTimeout(function () {
$("#infor").fadeOut("slow");
}, 1000);
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<button id="btnSave">Save Click</button>
<div class="hideme" id="infor">This is a test div</div>
$(document).ready(function () {
$("#infor").hide();
$("#btnSave").click(AlertSave);
});
function AlertSave() {
$("#infor").fadeIn("slow").delay(1000).fadeOut("slow");
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<button id="btnSave">Save Click</button>
<div class="hideme" id="infor">This is a test div</div>
Note: I would also advice you to change the .click()
handler.