需要使用 jquery 切换图像映射的属性 - Jquery .removeAttr

发布于 2024-08-20 00:28:24 字数 979 浏览 4 评论 0 原文

我正在尝试禁用图像映射 onClick - 最终我想在重新单击时启用它,但首先要做的事情。

因此,要禁用 imaeg 地图,我想在单击地图时从图像中删除属性“usemap”。

在标头中,我调用我的 JQuery:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
 <script type="text/javascript" src="jq/jquery.maphilight.js"></script>
 <script>
 $(function() {
  $('.map').maphilight();
 });
</script>

下面我尝试使用 .removeAttr 但没有返回:

    <div class="mapholder"><img class="map" src="img/map.png" width="517" height="352"    border="0" usemap="#usa"  /></div>
    <script>
  $("img.map").toggle(function(){
 $(this).removeAttr("usemap")
  .focus() 
},
function(){
$(this).addAttr("usemap")
  .focus()
  });
</script>

这是测试站点: http://quiznosforsale.com/open_house/

地图在底部,任何建议将不胜感激!

I'm trying to disable an image map onClick - and eventually I'd like to enable it if reclicked, but first things first.

So to disable the imaeg map I'd like to remove the attribute "usemap" from the image when one clicks on the map.

In the header I'm calling my JQuery:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
 <script type="text/javascript" src="jq/jquery.maphilight.js"></script>
 <script>
 $(function() {
  $('.map').maphilight();
 });
</script>

And below I'm attempting to use the .removeAttr but I'm getting no return:

    <div class="mapholder"><img class="map" src="img/map.png" width="517" height="352"    border="0" usemap="#usa"  /></div>
    <script>
  $("img.map").toggle(function(){
 $(this).removeAttr("usemap")
  .focus() 
},
function(){
$(this).addAttr("usemap")
  .focus()
  });
</script>

Here is the test site: http://quiznosforsale.com/open_house/

The map is at the bottom, any suggestions would be highly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

满栀 2024-08-27 00:28:24

尝试:

$("img.map").toggle(function(){
 $(this).removeAttr("usemap")
  .focus() 
},
function(){
$(this).addAttr("usemap")
  .focus()
});

try:

$("img.map").toggle(function(){
 $(this).removeAttr("usemap")
  .focus() 
},
function(){
$(this).addAttr("usemap")
  .focus()
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文