<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>17-jQuery的prop方法</title>
<script type="text/javascript" src ="https://code.jquery.com/jquery-1.12.4.js"></script>
<script>
$(function () {
/*
1.prop方法
和attr方法一样
2.removeProp方法
和removeAttr方法一样
*/
$span1 = $("span").eq(0).prop("demo","it666");
$("span").eq(1).prop("demo","lnj")
console.log($("span").prop("demo"));
$("span").removeProp("demo");
//prop不只能操作属性,还能操作属性节点
console.log($("span").prop("class"));
$("span").prop("class","box");
console.log($("input").prop("checked")); //true/false
console.log($("input").attr("checked")); //checked/undefined
});
</script>
</head>
<body>
<span class="span1" name="it666"></span>
<span class="span2" name="llj"></span>
<input type="checkbox" checked>
</body>
</html>