我有一个小的 .each() 循环来检查跨度是否可见,然后我想检查是否选中了该跨度标记的复选框。
功能是
function processReports(){
$("#processedReports").html('');
var repName = $("#reviewType").val();
var divHTML = "<table style='width: 300px;'><tr><td style='width:30%; text-align:left; font-weight:bold;'>Report</td><td style='font-weight:bold; width:50%; text-align:right; padding-right:4px;'>Date/Time Run</td><td style='font-weight:bold;'>Progress</td></tr>";
var d = new Date();
var strDate = (d.getMonth()+1) + "/" + d.getDate() + "/" + d.getFullYear();
var strTime = d.toLocaleTimeString();
$("#reportChecks span:visible").each(function(){
var reportName = $(this).attr("reportType");
**if($('input.checkbox').is(':checked')){**
divHTML += "<tr><td style='width:30%; text-align:left;' class='" + reportName +"' advID='" + $(this).text() + "'>" + reportName + "</td><td style='width:50%; text-align:right; padding-right:4px;'>" + strDate + "," + strTime + "</td><td><a href='/Applications/help/Reports/Prospect_reports/Prospect1ClickReview.pdf' target='_blank'>View</a></td></tr>";
}
//alert($(this).text());
});
divHTML += "</table>";
$("#processedReports").prepend(divHTML);
$("#processedReports").show();
$("#IndReports").show();
}
基本上我有 if($('input.checkbox').is('checked')){...... 不起作用。跨度标签中只有一个复选框,所以我要做的就是知道该元素是否被选中,如果它附加 divHTML,如果没有,继续循环谢谢!