HTML:
姓名:<input type="text"/><br/> <input type="checkbox" value="A" />A <input type="checkbox" value="B" />B <input type="checkbox" value="C" />C <input type="checkbox" value="D" />D<br/> <input type="button" value="click"/>
JS:
1.
$(document).ready(function(e) { var obj = $(":checkbox:eq(1)"); obj.prop("checked","checked"); });
2.
$(document).ready(function(e) { var obj = $(":checkbox:eq(3)"); obj.attr("checked",true); });
3.
$(document).ready(function(e) { var obj = $(":checkbox:eq(1)")[0]; obj.checked = "checked"; });
4.
$(document).ready(function(e) { var obj = $(":checkbox:eq(3)")[0]; obj.setAttribute("checked","checked"); });
时间: 2024-10-23 02:03:14