Check value of attr() and prop() - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:prop

Description

Check value of attr() and prop()

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("#p1").html("attr('checked'): " + $("input").attr('checked')
        + "<br>prop('checked'): " + $("input").prop('checked'));
    });/*from  w ww.  j a v a 2  s  .  c  o  m*/
});
</script>
</head>
<body>


<button>Check value of attr() and prop()</button>
<br><br>

<input id="check1" type="checkbox" checked="checked">
<label for="check1">Check me</label>
<p id="p1"></p>

</body>
</html>

Related Tutorials