Non draggable nested input
HTML
<div class="parent" draggable="true">
<input class="child" type="text" value="22.99" />
</div>
CSS
.parent {
height: 200px;
width: 200px;
background-color: pink;
}
.child {
margin-top: 20px;
}
JavaScript
;
(function($) {
// DOM Ready
$(function() {
$('input').on('mousedown', function(e) {
//e.stopPropagation();
$('div.parent').attr('draggable', false);
});
$(window).on('mouseup', function(e) {
$('div.parent').attr('draggable', true);
});
/**
* Added the dragstart event handler cause
* firefox wouldn't show the effects otherwise
**/
$('div.parent').on({
'dragstart': function(e) {
//e.stopPropagation();
var dt = e.originalEvent.dataTransfer;
if (dt) {
dt.effectAllowed = 'move';
dt.setData('text/html', '');
}
}
});
});
}(jQuery));