Jquery Draggable + Bring to Front

前端 未结 4 933
长情又很酷
长情又很酷 2021-01-21 13:43

I have a window with a number of chat DIV\'s where a user to chat to different people.

Currently the chat DIV\'s can be open and moved around but I can\'t see to get the

相关标签:
4条回答
  • 2021-01-21 13:52

    Though there is an option - 'stack' existing while initiating draggables like this -

    $('.draggable').draggable({
        stack: ".draggable"
    });
    

    But it is not working properly, So I have wrote a small library dragToFront playing with z-index. Following is the plunkr link

    https://embed.plnkr.co/mJqkxSJhf1Umg7r2oLQN/

    0 讨论(0)
  • 2021-01-21 13:54

    This should help

    $('div.chatMessenger').not(this).css('z-index', '100');
    $(this).css('z-index', '1000');
    

    inside on('mousedown') function.

    0 讨论(0)
  • 2021-01-21 13:58

    For several draggables where you want to bring one to front and reset others to back:

    $('.container').on('mousedown', function(event) { 
        $('.container').css('z-index','1');
        $( this ).css('z-index','1000');
    });
    
    0 讨论(0)
  • 2021-01-21 14:14

    I figured out that the easiest implementation is to move the div in the dom to the last position. so if you dont have to care about the position in the dom this is the easiest way without using z-index. i use this for positioning some sticky notes.

    $("#chatWrapper").on('mousedown', '.chatMessenger', function() {
        $(this).appendTo("#chatWrapper");
    });
    
    0 讨论(0)
提交回复
热议问题