如何在imgpreview插件中添加alt文本

时间:2012-10-24 00:05:29

标签: jquery

得到了这个地图区域

<area title="hello" alt="hi there" nohref="<?php bloginfo('template_url'); ?>/images/image1.jpg" shape="rect" coords="216,371,418,490" href="#" />

和这个jquery代码

$('#first area').imgPreview({
    containerID: 'imgPreviewWithStyles',
    imgCSS: {
        // Limit preview size:
        height: 200
    },
    // When container is shown:
    onShow: function(link){
        $('<span>' + $(link).text() + '</span>').appendTo(this);
    },
    // When container hides: 
    onHide: function(link){
        $('span', this).remove();
    }

});

如何在imgPreview插件创建的附加范围中输入显示地图区域替代文字的代码

我认为这是唯一需要更改的部分

$('<span>' + $(link).text() + '</span>').appendTo(this);

1 个答案:

答案 0 :(得分:0)

这里的工作小提琴http://jsfiddle.net/tariqulazam/3Yckp/

// When container is shown:
    onShow: function(link){
        $('<span>' + $(link).attr('alt') + '</span>').appendTo(this);
    }