Skip to content

Instantly share code, notes, and snippets.

@sakukode
Created January 14, 2019 12:02
Show Gist options
  • Select an option

  • Save sakukode/c3afc22f0fa2393cc53df51e1af74bc3 to your computer and use it in GitHub Desktop.

Select an option

Save sakukode/c3afc22f0fa2393cc53df51e1af74bc3 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Menampilkan pesan notifikasi dengan Toastr JS</title>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css">
<style type="text/css">
body {
margin-top: 50px;
}
</style>
</head>
<body>
<div>
<textarea id="message"></textarea>
<br/>
<p>Pilih Tipe Pesan</p>
<input type="radio" value="success" name="type" checked /> Sukses <br>
<input type="radio" value="info" name="type" /> Info <br>
<input type="radio" value="warning" name="type" /> Warning <br>
<input type="radio" value="error" name="type" /> Error <br>
<br>
<button id="btn-show">Tampilkan Pesan dengan Toastr</button>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
<script type="text/javascript">
$('#btn-show').click(function() {
var message = $('#message').val();
var $type = $('input[name=type]:checked').val();
toastr[$type](message);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment