attr(属性名) 获取属性
attr(属性名,属性值) 设置属性
<script >
$(function(){
//全选
$("#sex").change(function(){
var chk1= $(this).prop("checked")
$(":checkbox:not([id])").prop("checked",chk1)
})
//反选
$("#sex2").change(function(){
$(":checkbox:not([id])").each(function(index,item){
var ck=$(item).prop("checked")
$(item).prop("checked",!ck)
console.log(ck)
})
})
})
</script>
<body>
<form action="#">
<input type="checkbox" name="sex" id="sex">
<label for="sex">全选/全不选</label>
<input type="checkbox" id="sex2">
<label for="sex">反选</label>
</form>
<input type="checkbox" checked>
<input type="checkbox" checked="">
<input type="checkbox" checked="checked">
</body>
change 改变(事件)
prop 属性
:not([id]) 不同的id
html() div<span>span</span>(包含html标签的代码)
text() divspan (纯文本)
val() (交互控件【表单控件】的值)
没有参数时,获取带参数的值
<div>div<span>span</span></div>
$("div").text("<h1>h1</h1>");
text()不解析代码
$("div").html("<h1>h1</h1>");
html()解析代码
$("div").css("color","red");
.css操作行样式display
posted on
浙公网安备 33010602011771号