message like that
Swal.fire(
'Good job!',
'You clicked the button!',
'success'
)
When I click my button then I want to show that message
function alertMsg(){
Swal.fire(
'Good job!',
'You clicked the button!',
'success'
)
}
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.3.3/dist/sweetalert2.all.min.js"></script>
<button onClick="alertMsg()">Button</button>
There are different ways to achieve this, I don't know if your button has an id or class you can attach an event for that, you should use the on click event. Learn more about events here.
This is a simple example:
<button onclick="showSwalAlert()">My Button</button>
<script>
function showSwalAlert(){
Swal.fire(
'Good job!',
'You clicked the button!',
'success'
)
}
</script>