【发布时间】:2011-10-03 22:47:25
【问题描述】:
我正在尝试在 Drupal 站点的上下文中使用 jQuery。该脚本在包括 IE8 在内的其他浏览器中运行良好,但在 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', '')。 -
你用的是什么版本的jQuery?
-
removeClass() 没有任何区别。至于 jQuery 的哪个版本,它看起来是 Drupal 7 附带的 1.4.4 版本。
标签: jquery drupal internet-explorer-7 drupal-7 addclass