Determine which Area in a Map (imageMap) was clicked using JavaScript (or jQuery)

后端 未结 1 1723
情书的邮戳
情书的邮戳 2020-12-20 13:33

I\'m writing a mock up (using HTML, JS/jQuery) and CSS for a client which involves having a single image (of an interface) with an Map applied to it. For reasons I won\'t ex

相关标签:
1条回答
  • 2020-12-20 14:32

    There are different approaches. I guess the easiest would be this one:

    $("map[name=claas_ipad3] area").live('click', function () {
        alert($(this).attr('id')); 
    });
    

    Note that as of jQuery 1.7, the .live() method is deprecated and you should use .on() to attach event handlers:

    $("map[name=claas_ipad3] area").on('click', function () {
        alert($(this).attr('id')); 
    });
    
    0 讨论(0)
提交回复
热议问题