我正在使用 Jquery 和 JqueryUI 使网站上的一些元素可拖动,我希望它们在单击时出现在前面,但我遇到了问题 - 可拖动工作正常,但每个元素 (.flower) 只是保持它的顺序原来是。
 // jquery
$(function() {
  $( ".flower" ).draggable();
});
var zmax = 0;
$( '.flower' ).click( function () {
  $( this ).siblings( '.flower' ).each(function() {
    var cur = $( this ).css( 'z-index');
    zmax = cur > zmax ? $( this ).css( 'z-index') : zmax;
  });
$( this ).css( 'z-index', zmax+1 );
});
//html
<div id="flower1" class="flower"><img src="images/flowers/f1.png"></img></div>
<div id="flower2" class="flower"><img src="images/flowers/f2.png"></img></div>
<div id="flower3" class="flower"><img src="images/flowers/f3.png"></img></div>
//css
.flower {
    position: fixed;
     z-index: 0;
     left: 10px;
     top: 10px;
}
谢谢你的帮助。