assalamualaikum, warohmatullohi wabarokatuh.
wa alaikum salam warohmatullohi wabarokatuh.
bagaimana cara menggunakan switch pada materialize?
how to checked in materialized by id ?
berikut kodenya :
this is code :
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css"><script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script><form name="formnya"><p id="public">d</p> <div class="switch"> <label> Draft <input type="checkbox" name='post_type' id="d"> <span class="lever"></span> publish </label> </div></form><script type="text/javascript"> if ($('#d').prop('checked')== true){ alert("anda memilih public"); }else if ($('#d').prop('checked')==false){ alert('tersimpan draft'); }</script> |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<form name="formnya">
<p id="public">d</p>
<div class="switch">
<label>
Draft
<input type="checkbox" name='post_type' id="d">
<span class="lever"></span>
publish
</label>
</div>
</form>
<script type="text/javascript">
if ($('#d').prop('checked')== true){
alert("anda memilih public");
}else if ($('#d').prop('checked')==false){
alert('tersimpan draft');
}
</script>
setelah mengetahui hasilnya coba kamu hapus script checked nya untuk mengetahui hasilnya.
Terima Kasih
Thanks
TAG TAGS :
Jquery || how to if in jquery || cara if checked dengan jquery || materialize || cara checked menggunakan materialize || if condition checked redirect to index if condition not checked redirect to page different
0 comments:
Post a Comment