jquery简单入门
页面加载时加载 相当于 感觉
$(document).ready(function(){

})
简写:
$(function(){

});
1
js对象转换成JQ对象
$(js对象)
JQ对象---->js对象
KaTeX parse error: Expected \'EOF\', got \'#\' at position 3: (\"#̲id\").get(0) …(\"#id\")—JQ对象
或者 $(\"#id\")[0]
选择器类型
id选择器 ${“#id”}
标签选择器
#{‘input [name=“zhi”]:checked’}

类选择器
${.class}

获取单个checkbox选中项(三种写法):
$(“input:checkbox:checked”).val()
或者
$(“input:[type=‘checkbox’]:checked”).val();
或者
$(“input:[name=‘ck’]:checked”).val();

获取多个checkbox选中项:
KaTeX parse error: Expected \'}\', got \'EOF\' at end of input: …tion() { if ((this).attr(‘checked’) ==true) {
alert($(this).val());
}
});

设置第一个checkbox 为选中值:
$(‘input:checkbox:first’).attr(“checked”,‘checked’);
或者
$(‘input:checkbox’).eq(0).attr(“checked”,‘true’);

设置最后一个checkbox为选中值:
$(‘input

收藏 打印