图片映射onclick问题

Image map onclick problems

大家好,我的代码有问题:

$("#gotobikeblue").click(function(){
           
           $("#bikeblue").show();
           $("#motor").hide();
           $("#wheel").hide();

           
        return false;
    });
    
    $("#gotomotor").click(function(){
           
           $("#bikeblue").hide();
           $("#motor").show();
           $("#wheel").hide();
   
           
        return false;
    });
    
    $("#gotowheel").click(function(){
           
           $("#bikeblue").hide();
           $("#motor").hide();
           $("#wheel").show();
   
           
        return false;
    });
#bikeblue
{
display:none;
}

#wheel
{
display:none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<img src="http://i62.tinypic.com/2l8jmzo.jpg" alt="" usemap="#motor" id="motor"/>
<map  id="motor" name="motor">
<area id="gotobikeblue" alt="" title="" href="" shape="rect" coords="1135,13,1261,123" style="outline:none;" target="_self"     />
<area id="gotowheel" alt="" title="" href="" shape="rect" coords="1110,874,1265,997" style="outline:none;" target="_self"     />
</map>


<img src="http://i62.tinypic.com/14kv6zo.jpg" alt="" usemap="#bikeblue" id="bikeblue"/> 
<map id="bikeblue" name="bikeblue">
<area id="gotomotor" alt="" title="" href="" shape="rect" coords="10,9,103,92" style="outline:none;" target="_self"     />
<area id="gotowheel" alt="" title="" href="" shape="rect" coords="899,666,1010,756" style="outline:none;" target="_self"     />
</map>


<img src="http://i58.tinypic.com/2qvw12x.jpg" alt="" usemap="#wheel" id="wheel"/> 
<map id="wheel" name="wheel">
<area id="gotomotor" alt="" title="" href="" shape="rect" coords="13,12,164,109" style="outline:none;" target="_self"     />
<area id="gotobikeblue" alt="" title="" href="" shape="rect" coords="35,130,127,210" style="outline:none;" target="_self"     />
</map>

为什么点击 2-3 次后页面会重新加载?? 我需要页面不重新加载并单击缩略图让我看到相应的图像。 但是,如果将此代码用于两个图像,我不会遇到任何问题。当图像超过两个时,问题就来了。



不要 运行 这里的代码,它在这里不起作用。

好像是和多个元素ID相同(无效HTML)有关。

如果我将重复的 ID 更改为 类,该页面不再为我重新加载:

$(".gotobikeblue").click(function(){
    $("#bikeblue").show();
    $("#motor").hide();
    $("#wheel").hide();

    return false;
});

$(".gotomotor").click(function(){
    $("#bikeblue").hide();
    $("#motor").show();
    $("#wheel").hide();

    return false;
});

$(".gotowheel").click(function(){
    $("#bikeblue").hide();
    $("#motor").hide();
    $("#wheel").show();

    return false;
});

和 HTML:

<img src="http://i62.tinypic.com/2l8jmzo.jpg" alt="" usemap="#motor" id="motor"/>
<map  id="motor" name="motor">
<area class="gotobikeblue" alt="" title="" href="" shape="rect" coords="1135,13,1261,123" style="outline:none;" target="_self"     />
<area class="gotowheel" alt="" title="" href="" shape="rect" coords="1110,874,1265,997" style="outline:none;" target="_self"     />
</map>


<img src="http://i62.tinypic.com/14kv6zo.jpg" alt="" usemap="#bikeblue" id="bikeblue"/> 
<map id="bikeblue" name="bikeblue">
<area class="gotomotor" alt="" title="" href="" shape="rect" coords="10,9,103,92" style="outline:none;" target="_self"     />
<area class="gotowheel" alt="" title="" href="" shape="rect" coords="899,666,1010,756" style="outline:none;" target="_self"     />
</map>


<img src="http://i58.tinypic.com/2qvw12x.jpg" alt="" usemap="#wheel" id="wheel"/> 
<map id="wheel" name="wheel">
<area class="gotomotor" alt="" title="" href="" shape="rect" coords="13,12,164,109" style="outline:none;" target="_self"     />
<area class="gotobikeblue" alt="" title="" href="" shape="rect" coords="35,130,127,210" style="outline:none;" target="_self"     />
</map>