1、在页面的某个具有id的element内插入其他element,并给其增加悬浮提示。
$(‘#id‘).after(‘<div id=‘box‘></div>‘); $(‘#box‘).attr(‘title‘,‘beautiful‘).tooltip();
after() --在被选中的元素之后插入内容
attr("attributeName",value) -- 为指定元素设置一个或多个属性,attributeName属性名,value 为这个属性设置的值
tooltip() -- 被选元素具有title的属性值,当鼠标悬浮时则弹出提示框。
联想:append() --在被选元素的结尾插入内容
before() --在被选元素之前插入内容
prepend() --在被选元素的开头插入内容
2、获取单选框/复选框
//选中的name为identity单选框的value值
$("input[name=identity]:checked").val();
//选中的单选框的value值
$("input[type=‘radio‘]:checked").val();
//获取被勾选的单选框对象
$(‘input[name="identity"]‘).filter(‘:checked‘);
//获取被勾选的复选框对象
$("input[type=‘checkbox‘]").filter(‘:checked‘)
//获取被勾选的复选框对象
$("input[type=‘checkbox‘]:checked").val([]);
3、遍历
$("input[name=identity]").each(function(i){
alert($(this).val());
});
遍历name为identity的所有input对象,并且alert对应的value值
原文:http://www.cnblogs.com/1rookie/p/6408079.html