in this tutorial give details of how to create alert OR toast OR tooltip on time basis, i.e. auto hide.
$(document).ready(function(){
$('#myBtn').click(function(){
$('.toast').toast({delay: 3000});
$('.toast').toast('show');
});
});
& call bootstrap supported files
finally, the code like below,
<!DOCTYPE html>
<html lang="en">
<head>
<title>alert style </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container mt-3">
<h1>create toast or alert</h1>
<p>In this example, it will take 3 seconds to hide the toast(alert box), once it is shown. </p>
<button type="button" class="btn btn-primary" id="myBtn">Show Toast</button>
<div class="toast mt-3">
<div class="toast-header">
Toast Header
</div>
<div class="toast-body">
Some text inside the toast body
</div>
</div>
</div>
<script>
$(document).ready(function(){
$('#myBtn').click(function(){
$('.toast').toast({delay: 3000});
$('.toast').toast('show');
});
});
</script>
</body>
</html>
in above use jquery set delay in alert box and autohide.
useful to show messages or warning, success, error messages .
for example data is saved message for this also good to use toast.
No comments:
Post a Comment