Im trying to make checkbox fire an alert if it is checked. This is my code below. What am I doing wrong here?
var $isgdpr = $("#isgdpr").is(':checked');
if ($isgdpr) {
  alert('Checked!');
};<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="switch">
    <input type="checkbox" id="isgdpr" checked="checked">
</label> 
     
    