I am having a code in _layout.cshtml.
@if (TempData["SuccessMessage"] != null)
{
<div class="alert alert-success">
@TempData["SuccessMessage"];
</div>
}
And in javascript
$(function() {
$(".alert alert-success").fadeOut("slow");
});
But the div is not fading out. Please suggest what I am doing wrong.
jQuery Docs – Class Selectors has an example that is quite relevant (Finds the element with both “myclass” and “otherclass” classes.)
Try changing:
To:
or you could try
.filter():However, this method will be slightly slower since you are first compiling a set of all match
.alertelements and then filtering those to compile a second set or those containing.alert-success.Find more info in a similar post here