2014年7月3日 星期四

JQuery Div Hide&Show

這段程式碼主要用在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;
    }
});

1 則留言: