jquery prop方法
<script>
$(function(){
console.log( $("input").prop("checked"));//prop用于判断只有true和false的属性的属性节点,其只返回ture或false
console.log($("input").attr("checked"));//attr判读那此类型属性节点只会返回此节点名称或者undefined
})
</script>
</head>
<body>
<input type="checkbox" checked>
</body>
结果:
<script>
$(function(){
console.log( $("input").prop("checked"));
console.log($("input").attr("checked"));
})
</script>
</head>
<body>
<input type="checkbox">
</body>
结果:
结论:
1.prop方法和attr方法类似,也可增加属性节点、修改属性节点、删除属性节点
2.具有true和false两个属性的属性节点,如checked、selected、disabled适合使用prop方法,其余的可使用prop也可用attr方法