這段程式碼主要用在DIV顯示跟隱藏
剛好最近在幫客戶家功能,使用GridView做呈現
如果你非常懶的改後端,那就讓前端去幫你處理吧
$('#dvdeatil div').each(function () {
var data = $("#" + this.getAttribute('id')).attr("title");
var county = data ? data.split(",")[0] : ""
switch ($("#<%=ddlcounty.ClientID %>").find(":selected").text()) {
case "全部":
$("#tr_" + this.getAttribute('id')).show();
break;
default:
$("#tr_" + this.getAttribute('id')).show();
if (county != $("#<%=ddlcounty.ClientID %>").find(":selected").text()) {
$("#tr_" + this.getAttribute('id')).hide();
}
break;
}
});
受益良多
回覆刪除