Jquery hovercard

丶灬走出姿态 提交于 2019-12-23 20:13:50

问题


I'm using http://designwithpc.com/Plugins/Hovercard , but I can't find out how to declare a var on hovercard. Every job-desc has his own ID and it should be call when hovering labels. I hope I explained well.

<li id="577" class="item">
    <span>
        <h3 class="padding-left"><label class="labeldesc" for="">Text</label></h3>
    </span>
    <span class="job-descr" id="hiden-577">TextTextTextTextText</span>
</li>
<li id="588" class="item">
    <span>
        <h3 class="padding-left"><label class="labeldesc" for="">Text2</label></h3>
    </span>
    <span class="job-descr" id="hiden-588">Text2Text2Text2Text2Text</span>
</li>

Jquery code:

$('.labeldesc').hovercard({
    var idhover=$(this).closest('.item').attr('id');
    detailsHTML:$("#hiden-" + idhover).html()
});

回答1:


Give this a shot: http://jsfiddle.net/X2q9z/

$('.labeldesc').hovercard({
    onHoverIn: function() {
        var txt = $($(this).parents('li')[0]).find('.job-descr').html();
        $(this).find('.hover_text').html(txt);
    },
    detailsHTML: '<div class="hover_text"></div>'
});



回答2:


First of all your jQuery Code has issue. You cannot use var inside calling hovercard function.

I update it as you wanted. Please take a loot at this: http://jsfiddle.net/cnCmN/

$('.labeldesc').each(function(){
    $(this).hovercard({
        detailsHTML: $("#hiden-"+$(this).closest('.item').attr('id')).html()
    });
});


来源:https://stackoverflow.com/questions/8715982/jquery-hovercard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!