2011-03-15 172 views
0

下面是一些asp.net標記:IE7和CSS顯示屬性

<tr style="display:none" id="AllInRateRow"> 
        <td id="td6"> 
          All-In Fixed Rate <span id="allInRateHelp" /> 
        </td> 
        <td id="td7"> 
         <%= Html.TextBoxFor(m => m.FixedRate, new { @class = "economicTextBox", propertyName = "FixedRate", dontRegisterNewIndication = true })%> % 
        </td> 
       </tr> 

       <tr style="display:none" id="ProfitRow"> 
        <td id="td93"> 
         Your Swap Profit 
        </td> 
        <td id="yourSwapProfit"> 
         <%= Html.TextBoxFor(m => m.Fees.ProfitAmount, new { @class = "economicTextBox", propertyName = "Fees.ProfitAmount", dontRegisterNewIndication = true })%> 
          <%= Html.RadioButtonFor(m => m.Fees.ProfitType, (int)Chatham.Enumerations.IndicationProfitType.bps, 
                new { label = "bps", propertyName = "Fees.ProfitType", dontRegisterNewIndication = true })%> 
         bps 
         <%= Html.RadioButtonFor(m => m.Fees.ProfitType, (int)Chatham.Enumerations.IndicationProfitType.CurrencyAmount, 
                   new { label = "$", propertyName = "Fees.ProfitType", dontRegisterNewIndication = true })%> 
         $ 
        </td> 
       </tr> 

我認爲這是與CSS的顯示特性的問題。它不上這是正確的事情頁面加載顯示出來,但隨後的這個選擇應該改變:

<td id="td4"> 
         Options <span id="solverHelper" /> 
        </td> 
        <td id="solveType"> 
         <%=Html.DropDownListFor(m => m.Fees.CalculationSource, DropDownData.SolverOptionsList(), 
                   new { propertyName = "Fees.CalculationSource", dontRegisterNewIndication = true })%> 
        </td> 

而這些事情發生經過的JQuery設置CSS和改變它像這樣:

var pricingOptions = $("#Fees_CalculationSource").val(); 
      if(pricingOptions == <%= ((int)Chatham.Web.Models.Indications.SwapModel.SolverOptions.AllInRate).ToString() %>) 
      { 
       $("#AllInRateRow").css("display", "none"); 
       $("#ProfitRow").css("display", "table-row"); 
       if(canExcludeFees) $("#IncludeFeesOption").css("display", "table-row"); 
       else $("#IncludeFeesOption").css("display", "none"); 

      } 
      else if (pricingOptions == <%= ((int)Chatham.Web.Models.Indications.SwapModel.SolverOptions.Profit).ToString() %>) 
      { 
       $("#AllInRateRow").css("display", "table-row"); 
       $("#ProfitRow").css("display", "none"); 
       $("#IncludeFeesOption").css("display", "table-row"); 
       if(canExcludeFees) $("#IncludeFeesOption").css("display", "table-row"); 
       else $("#IncludeFeesOption").css("display", "none"); 

      } 
      else if (pricingOptions == <%= ((int)Chatham.Web.Models.Indications.SwapModel.SolverOptions.None).ToString() %>) 
      { 
       $("#AllInRateRow").css("display", "table-row"); 
       $("#ProfitRow").css("display", "none"); 
       $('input[propertyname=Fees.IncludeFeeIndicator]:eq(1)').attr('checked', 'checked'); 
       $(

"#IncludeFeesOption").css("display", "none"); 
     } 

我認爲IE7無法將CSS設置爲錶行屬性,但它可以與'none'一起工作。

我正確嗎?如果我是,那麼什麼是解決方法?

回答

1

如果我記得正確的話IE7使用display:block。顯示元素最簡單的方法是從jQuery調用show/hide方法,而不是試圖自己控制顯示屬性。

$("#AllInRateRow").show(); 
$("#ProfitRow").hide(); 

這將在所有的瀏覽器,你將不必擔心瀏覽器的細節。