html页面中的代码
jqury代码
$("#filter").click(function () { for (var i = 1; i <= filterNum; i++) { if ($("#filterValue" + i).val() == null || $("#filterValue" + i).val() == "") { alert($("#filterValue" + i).val()); continue; } else { if ($("#inputPropertyName" + i).val() == "MetricId") { dataSource.filter({ field: $("#inputPropertyName" + i).val(), operator: $("#inputOperation" + i).val(), value: parseInt($("#filterValue" + i).val()) }); } else { dataSource.filter({ field: $("#inputPropertyName" + i).val(), operator: $("#inputOperation" + i).val(), value: $("#filterValue" + i).val() }); } } } }); $("#add").click(function () { filterNum++; var newDiv = document.createElement('div'); var str = ""; newDiv.innerHTML = str; newDiv.setAttribute("Id", "div" + filterNum); $("#filterDiv").append(newDiv); }); $("#reset").click(function () { dataSource.filter({ field: "MetricName", operator: "contains", value: "" }); });
删除的jquery
function delItem(i) { $("#div" + i).remove(); }