2013-07-26 25 views
0

我有一個下拉框,使用jquery .html函數填充div,當下​​拉列表中的選擇發生變化時。IE8的jQuery的HTML不能正確顯示

這在所有瀏覽器中都能正常工作,除了在IE8中查看網站時它有一些顯示問題。

我檢查了我的Javascript中的所有標記,並且所有html元素都已正確關閉並嵌套。這裏是我的代碼:

HTML:

<form action="/" method="post" id="selectClub">  
    <p>Thanks for thinking about joining FitSpace. Our five step joining process takes less than 5 minutes, and is quick, easy and all online. To get started, just choose the club you would like to join..</p> 
    <label for="chooseClub">Choose Club</label> 
    <select name="chooseClub">  
     <option value="">-- Please Select --</option> 
     <?php foreach($this->clubs as $club) { ?> 
      <option value="<?php echo $club['GYMGUID']; ?>"><?php echo $club['GYMNAME']; ?></option> 
     <?php } ?> 
    </select> 
</form> 
<div id="ratesWrapper"> 

</div> 

的jQuery:

if (data.result = true) { 
var html = ""; 
jQuery.each(data.rates, function (i, v) { 
    var link = "<?php echo JRoute::_('index.php?option=com_signup&view=memberForm1'); ?>"; 
    var imgLink = "<?php echo addslashes($this->baseurl . '/templates/protostar/images/bg_pricing_join_now.png'); ?>"; 
    html += "<a class='rate' href='" + link + "&GYMGUID=" + v.GYMGUID + "&RATEGUID=" + v.RATEGUID + "'>"; 
    html += "<h4><img src='" + imgLink + "' />" + v.RATENAME + "</h4>"; 
    if (v.RATENAME.indexOf('Value') > -1) { 
     html += "<p class='time'>Monthly</p>"; 
    } else if (v.RATENAME.indexOf('Flex') > -1) { 
     html += "<p class='time'>Monthly</p>"; 
    } else if (v.RATENAME.indexOf('Annual') > -1) { 
     html += "<p class='time'>Annual</p>"; 
    } 
    if (v.RATENAME.indexOf('Annual') > -1) { 
     html += "<p class='ratePrice'>&pound;" + v.RATE + " annual fee</p>"; 
    } else { 
     html += "<p class='ratePrice'>&pound;" + v.RATE + " per month</p>"; 
    } 
    if (v.RATENAME.indexOf('Value') > -1) { 
     html += "<p class='signUp'>With a one-off &pound;29 joining fee</p>"; 
     html += '<p>18 months minimum term<br /> Paid by Direct Debit monthly</p>'; 
    } else if (v.RATENAME.indexOf('Flex') > -1) { 
     html += '<p class="signUp">With a one-off &pound;29 joining fee</p>'; 
     html += "<p>No Contract, but you need to give us one month's notice to cancel.</p>"; 
     html += "<p>Paid by Direct Debit monthly</p>"; 
    } else if (v.RATENAME.indexOf('Annual') > -1) { 
     html += "<p class='signUp'>With NO joining Fee.</p>"; 
     html += '<p>12 months membership<br /> Paid by one-off Direct Debit</p>'; 
    } 
    html += "<p class='clickHere'>Click here to join!</p>"; 
    html += "</a>"; 
}); 
html += "<ul class='signupBottomBoxes'>"; 
html += "<p>All memberships include:</p>"; 
html += "<li>Proximity Membership card which provides Unlimited Use</li>"; 
html += "<li>Join One Club - use them all</li>"; 
html += "<li>Free Induction</li>"; 
html += "</ul>"; 
} 

jQuery('#ratesWrapper').html(html); 
jQuery('#ratesWrapper').hide().fadeIn('slow'); 

} 

當我檢查使用IE8 IE Web開發工具欄生成的標記顯示爲這樣的標記:

<div id="ratesWrapper"/> 

我不確定爲什麼會發生這種情況。有人能指出我的方向嗎? 感謝

它應該是怎樣看:

enter image description here

如何它看起來在IE8

enter image description here

+0

'#ratesWrapper' div只是在IE檢查器中自我關閉 - 這很好,因爲它沒有內部元素。爲什麼在IE8中無法正確顯示? –

+0

是的,這很奇怪,因爲我不知道它爲什麼會自我封閉。我將添加屏幕截圖以顯示不同之處。 – devoncrazylegs

+0

你使用的是什麼jQuery版本?你在Ie8控制檯中有任何錯誤嗎? – Spudley

回答

0

好,我已經找到了問題。我使用的CSS3選擇器的樣式,不幸的是不能在IE8中工作。希望將來這可以幫助任何人。