要利用jquery获取checkbox的文本描述,用下面语句就可以了。
$("#knowfrom").find("input[type='checkbox']:checked").siblings().text();
实例二
<td><input id= name="knowfrom" type="checkbox" value="" /> <label>tv</label></td>
$("#knowfrom").next().text()
看一个完整详细实例
<td><input name="knowfrom" type="checkbox" value="" /> tv</td>
jquery代码
function getselectedtext(name) {
// if (2>1) return "";
var value = "";
$(":input[name='"+name+"']").filter("[checked=true]").each(function() {
var $obj=this;
if (this.checked) {
if (value == "") value += $obj.siblings().text();
else value += "-" + $obj.siblings().text();
}
});return value;
}
时间: 2024-08-29 09:19:46