我想在Drupal站點的上下文中使用jQuery。該腳本在其他瀏覽器(包括IE8)中運行正常,但在IE7中它部分崩潰。在Drupal站點中的jQuery addClass()函數在IE7中不工作
示例腳本代碼:
function showEducation() {
jQuery('#map-overlay').attr('class','').addClass('education');
jQuery('#map-legend-image').attr('src','/sites/all/images/map/legend-education.png');
}
...用於如何或隱藏地圖圖像上的覆蓋,以及改變SRC圖像地圖圖例:
<div id="map">
<img id="map_image" src="[map path]" />
<div id="map-overlay"></div>
<div id="map-legend">
<img src="[legend path]" usemap="#map-legend-imageMap" id="map-legend-image" />
<map name="map-legend-imageMap" id="map-legend-imageMap">
<area shape="rect" coords="12,11,271,66" href="javascript:showEducation()" />
</map>
</div>
</div>
點擊圖片地圖的適當區域時,圖例會更新,但覆蓋圖不會。
我在IE7中遇到了很多addClass()的問題,但沒有一個問題看起來完全相同,也沒有提出相應的解決方案。
用'removeClass()'交換'attr('class','')'。 – alex
您使用的是什麼版本的jQuery? –
removeClass()沒有什麼區別。至於哪個版本的jQuery,它看起來是1.4.4,這是Drupal 7附帶的版本。 –