I'm looking to make a jQuery draggable div come to the front when it's clicked. I came across this post, and tried creating a JsFiddle based on it, but couldn't get it to work. Any ideas on what I might be missing? Thanks!
Here's the link to the JsFiddle I made. The elements can be dragged and brought to the front while dragging, but simply clicking them doesn't bring them forward. Is there a z-index conflict happening? JSfiddle
Below is the code snippet: HTML
<div>
<div id="box1" class="front-on-click"></div>
<div id="box2" class="front-on-click"></div>
<div id="box3" class="front-on-click"></div>
<div id="box4" class="front-on-click"></div>
Javascript:
$(document).ready(function() {
$('#box1,#box2,#box3,#box4').draggable({stack: "div"});
$('.front-on-click').click(function(){
$('.front').removeClass('front');
$(this).addClass('front');
});
});
Appreciate any help!