Ada*_*dam 2 html css jquery jquery-ui
我有一个窗口,其中有一些聊天DIV用户可以与不同的人聊天.
目前,聊天DIV可以打开并移动,但我看不到将当前选择的DIV设置在前面.例如:当你在DIV上徘徊时,它会进入前景.
HTML:
<div id="1000000001" class="chatMessenger">
<div class="chatMessengerContainer">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
div.chatMessenger {
position: absolute;
top: 50px;
left: 50px;
width: 250px;
height: 300px;
background-color: white;
z-index: 100;
border: 1px solid black;
}
Run Code Online (Sandbox Code Playgroud)
JQUERY:
// JQUERY UI Draggable - Initialize
$('div#'+memberID).draggable({
containment: $('div#chatWrapper')
});
// JQUERY UI Draggable - Setting the Stack
$(document).on('mousedown','div.chatMessenger', function() {
alert('chat mouse down...');
//var stack = $( ".selector" ).draggable( "option", "stack" );
$(this).draggable( "option", "stack", ".products" );
});
Run Code Online (Sandbox Code Playgroud)
警报在mousedown中触发,因此这是找到正确的元素.
我看过Draggable z-index和stack但是我无法工作.
会有很多聊天DIV同时打开,所选择的人需要坐在前面.
谢谢.
这应该有所帮助
$('div.chatMessenger').not(this).css('z-index', '100');
$(this).css('z-index', '1000');
Run Code Online (Sandbox Code Playgroud)
内on('mousedown')功能.