When I click the button, the message is displayed in the top-right. Only after one or two attempts, it is positioned in the top-center. But when submitting a form it should come in the top-center in the first click itself. Could anyone please tell me why it happens this way and how it can be corrected? I have included the code snippet below.
<!DOCTYPE html>
<html>
<head>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
<link rel="stylesheet"
href="http://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css">
</head>
<body>
<p>toast-top-center</p>
<button onclick="myFunction()">Click Here</button>
<p id="demo"></p>
<script>
function myFunction() {
Command: toastr["error"]
("I'm not in the top-center!")
toastr.options = {
"closeButton" : false,
"debug" : false,
"newestOnTop" : false,
"progressBar" : false,
"positionClass" : "toast-top-center",
"preventDuplicates" : false,
"onclick" : null,
"showDuration" : "300",
"hideDuration" : "1000",
"timeOut" : "5000",
"extendedTimeOut" : "1000",
"showEasing" : "swing",
"hideEasing" : "linear",
"showMethod" : "fadeIn",
"hideMethod" : "fadeOut"
}
}
</script>
</body>
</html>