HTML
xxxxxxxxxx
1
<div aria-live="polite" aria-atomic="true" id="popover">
2
<div class="toast" style="position: absolute; top: 0; right: 0;" data-autohide="false">
3
<div class="toast-header">
4
<svg class="rounded mr-2" width="20" height="20" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice"
5
focusable="false" role="img">
6
<rect fill="#007aff" width="100%" height="100%" /></svg>
7
<strong class="mr-auto">Bootstrap</strong>
8
<small>11 mins ago</small>
9
<button type="button" class="ml-2 mb-1 close" id="btnClose" data-dismiss="toast" aria-label="Close">
10
<span aria-hidden="true">×</span>
11
</button>
12
</div>
13
<div class="toast-body">
14
Hello, world! This is a toast message.
15
</div>
16
</div>
17
</div>
18
19
<div class="container">
20
21
<div class="row justify-content-center pt-5 mt-5">
22
<div class="col-md-1">
23
<button type="button" class="btn btn-primary" id="btnId">TL</button>
24
</div>
25
<div class="col-md-1">
26
<button type="button" class="btn btn-primary" id="btnId2">T</button>
27
</div>
28
<div class="col-md-1">
29
<button type="button" class="btn btn-primary" id="btnId3">TR</button>
30
</div>
31
<div class="col-md-1">
32
<button type="button" class="btn btn-primary" id="btnId4">RT</button>
33
</div>
34
<div class="col-md-1">
35
<button type="button" class="btn btn-primary" id="btnId5">R</button>
36
</div>
37
<div class="col-md-1">
38
<button type="button" class="btn btn-primary" id="btnId6">RB</button>
39
</div>
40
<div class="col-md-1">
41
<button type="button" class="btn btn-primary" id="btnId7">BR</button>
42
</div>
43
<div class="col-md-1">
44
<button type="button" class="btn btn-primary" id="btnId8">B</button>
45
</div>
46
<div class="col-md-1">
47
<button type="button" class="btn btn-primary" id="btnId9">BL</button>
48
</div>
49
<div class="col-md-1">
50
<button type="button" class="btn btn-primary" id="btnId10">LB</button>
51
</div>
52
<div class="col-md-1">
53
<button type="button" class="btn btn-primary" id="btnId11">L</button>
54
</div>
55
<div class="col-md-1">
56
<button type="button" class="btn btn-primary" id="btnId12">LT</button>
57
</div>
58
59
60
</div>
CSS
1
1
JS
xxxxxxxxxx
1
const clearPopup = function(){
2
//remove any properties you added to bring back default html look of popup
3
$('.toast .toast-header svg rect').css('fill', '#007aff');
4
$('.toast .toast-header small').removeClass('text-danger');
5
$('.toast').removeClass('bg-danger');
6
$('.toast').removeClass('animated bounceInLeft');
7
}
8
9
//clear style of popup on clicking close button in popup
10
$('#btnClose').click(clearPopup);
11
12
document.getElementById('btnId').addEventListener('click', function () {
13
clearPopup(); //add if you want to be sure you are working with default look of popup
14
$(".toast").css({"left":"10%","top":"0%"}); // classic position
15
// now add your styling to 'toast' with Jq Selector and add properties
16
$('.toast .toast-header svg rect').css('fill', '#ffffff'); // eddits color of rounded square
17
$('.toast .toast-header small').addClass('text-danger'); //eddits color of time text in header
18
$('.toast').addClass('bg-danger'); //eddits background of popup
19
// After showing notification add animation with classes
20
$('.toast').addClass('animated bounceInLeft');
21
$('.toast').toast('show');
22
// Setting hide after 10s
23
setTimeout(function () {
24
clearPopup();
25
$('.toast').toast('hide');
26
}, 10000);
27
});
28
29
document.getElementById('btnId2').addEventListener('click', function () {
30
clearPopup();
31
$(".toast").css({"left":"40%","top":"0%"});
32
$('.toast').toast('show');
33
});
34
35
document.getElementById('btnId3').addEventListener('click', function () {
36
clearPopup();
37
$(".toast").css({"left":"70%","top":"0%"});
38
$('.toast').toast('show');
39
});
40
41
document.getElementById('btnId4').addEventListener('click', function () {
42
clearPopup();
43
$(".toast").css({"left":"85%","top":"10%"});
44
$('.toast').toast('show');
45
});
46
47
document.getElementById('btnId5').addEventListener('click', function () {
48
clearPopup();
49
$(".toast").css({"left":"85%","top":"40%"});
50
$('.toast').toast('show');
51
});
52
53
document.getElementById('btnId6').addEventListener('click', function () {
54
clearPopup();
55
$(".toast").css({"left":"85%","top":"80%"});
56
$('.toast').toast('show');
57
});
58
59
document.getElementById('btnId7').addEventListener('click', function () {
60
clearPopup();
61
$(".toast").css({"left":"70%","top":"91%"});
62
$('.toast').toast('show');
63
});
64
65
document.getElementById('btnId8').addEventListener('click', function () {
66
clearPopup();
67
$(".toast").css({"left":"40%","top":"91%"});
68
$('.toast').toast('show');
69
});
70
71
document.getElementById('btnId9').addEventListener('click', function () {
72
clearPopup();
73
$(".toast").css({"left":"10%","top":"91%"});
74
$('.toast').toast('show');
75
});
76
77
document.getElementById('btnId10').addEventListener('click', function () {
78
clearPopup();
79
$(".toast").css({"left":"0%","top":"80%"});
80
$('.toast').toast('show');
81
});
82
83
document.getElementById('btnId11').addEventListener('click', function () {
84
clearPopup();
85
$(".toast").css({"left":"0%","top":"40%"});
86
$('.toast').toast('show');
87
});
88
89
document.getElementById('btnId12').addEventListener('click', function () {
90
clearPopup();
91
$(".toast").css({"left":"0%","top":"10%"});
92
$('.toast').toast('show');
93
});
Console errors: 0