I recently started using Sweetalert but now I don't understand why it doesn't work.
I made a function that retrieves the value of a button that I tested with alert (and it works) but as soon as I put it with sweetalert, the button is validated directly without the sweetalert being displayed.
function dosomething(val) {
if (val === "Warning") {
swal({
html: 'Warning !!!',
icon: 'warning',
confirmButtonColor: '#0A717D',
confirmButtonText: 'Ok',
});
}
};
<link href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js"></script>
<link rel="stylesheet" href="src/js/jquery-ui.min.css">
<button type="submit" name="besoin" onclick="dosomething(this.value)" value="Warning">Do something</button>