jQuery中的prop的方法

<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <title>prop</title>
</head>
<body>
<input type="button" value="选中">
<input type="button" value="不选中">
<input type="checkbox" id="ck">
<script src="jquery-1.12.4.js"></script>
<script>
  //对于布尔类型的属性,不要attr方法,应该用prop方法 prop用法跟attr方法一样。
  $("input").eq(0).click(function(){
    $("input").eq(2).prop("checked",true);
  });
    $("input").eq(1).click(function(){
    $("input").eq(2).prop("checked",false);
  });
</script>
</body>
</html>

 

 

  

posted @ 2020-04-17 11:46  迷幻天空岛  阅读(266)  评论(0编辑  收藏  举报