Search code examples
jqueryareaimagemap

Setting ALT as ID


$('area').qtip({
    content: $('#whatever-this-area-tags-alt-is'),
    position: {
        my: 'top left',    
        at: 'middle'
    },
    show: { delay: 0 },
    hide: { delay: 200 }
});

I'd like to set content ID to whatever the current area's alt is.

Thanks!


Solution

  • You can use a .each() to loop through and use this to refer to the current <area> inside the loop, like this:

    $('area').each(function() {
      $(this).qtip({
        content: $("#" + $(this).attr("alt")),
        position: {
            my: 'top left',    
            at: 'middle'
        },
        show: { delay: 0 },
        hide: { delay: 200 }
      });
    });