
代替js字符拼接
1 2 3 4
| $('<div/>',{ text: 'Div text', class: 'className' }).appendTo('#parentDiv');
|
设置radio选中用法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| <input type="radio" name="sex" id="man_radio" value="1" />男 <input type="radio" name="sex" id="woman_radio" value="0" />女
$('#man_radio').attr(checked, true);
$("input[name=sex]:eq(0)").attr("checked",true);
$("input[name=sex][value=# ").attr("checked",true);
$("#man_radio").attr("checked","checked"); $("#man_radio").removeAttr("checked");
$(input:radio:checked).val();
$("input[type=radio]:checked").val();
$("input[name=rd]:checked").val();
$("input[name=sex]").attr("cheked")
|
获取checkbox的属性
jQuery中的attr()与prop()设置属性、获取属性的区别
获取checkbox的属性或者设置checkbox选中或不选中
1 2 3 4 5 6 7 8 9 10 11 12 13
| $("#editForm").find("input[type='checkbox']").prop("checked", false);
$("#editForm").find("input[type='checkbox']").prop("checked", true);
|
jQuery将模板转换成dom对象
1 2 3
|
var dom = $(html).get(0);
|
参考
- https://blog.51cto.com/caixia/1734341
- https://blog.csdn.net/chenchunlin526/article/details/77426796
- https://unsplash.com/photos/0kIdrNdFJqs