开发者

How can I keep a mouseover'd DIV visible via jQuery?

开发者 https://www.devze.com 2023-03-07 05:20 出处:网络
Okay.. a bit complicated of a question. I have a DIV that appears when you mouseover a TR. $(\".alignment_tr\").hover( function() {

Okay.. a bit complicated of a question. I have a DIV that appears when you mouseover a TR.

$(".alignment_tr").hover( function() {
    console.log(开发者_开发知识库 "alignmententer" + triggerMouseover );
        var tid = $(this).find( ".hidden_inp_selected_alignment" ).val();
        var element = $(this);

        if( ! element.hasClass( "mouseover-tooltip" ) )
        {
            $.ajax( {
                url: Drupal.settings.jstools.basePath + "?q=search/mouseover_info",
                dataType: 'json',
                data: { "tid": tid },
                success: function( response ) {
                        $(".mouseover-tooltip .top-level").html( response.genre );
                        $(".mouseover-tooltip .second-level").html( response.name );
                        $(".mouseover-tooltip .description").html( response.description );
                        $(".mouseover-tooltip").css( {
                            left: element.position().left + ( element.width() * 0.75 ),
                            top: element.position().top - element.height() / 2,
                        } );
                        if( $(".mouseover-tooltip").css( "display" ) == "none" )
                        {
                            $(".mouseover-tooltip").fadeIn();
                        }
                    }
                });
        }
    },
    function() {
    console.log( "alignmentleave" + triggerMouseover );
        setTimeout( fadeMouseover, 5000 );
    }
);

I'm trying to get it so that when you mouse over the DIV, it doesn't just disappear. Any tips?

CLARIFICATION Right now, when you mouseover the TD, the DIV appears. I rigged it so that when you mouseover the DIV, it stays (used to disappear). But now the DIV doesn't disappear when your mouse leaves the TR AND leaves the DIV.


If the div is absolutely positioned, which I believe it is, place it within the tr. In that way, your mouse being over the div will count as it being over the td as well. That way your mouse being over the div or the tr will not trigger mouseleave.

A fiddle:

http://jsfiddle.net/mHCNj/1/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号