Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery hovercard

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()
});
like image 766
alexandra Avatar asked Jul 13 '26 22:07

alexandra


2 Answers

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>'
});
like image 58
Ayman Safadi Avatar answered Jul 15 '26 10:07

Ayman Safadi


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()
    });
});
like image 22
Qorbani Avatar answered Jul 15 '26 11:07

Qorbani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!