$(function () {
$("#test").draggable({
handle: "#testheader",
containment: 'window'
});
});
$('p#exit').click(function () {
$('#test').hide();
});
});
<div id="test"><div id="testheader"><p id="exit">Exit</p></div></div>
当我单击 p 元素时,它不会退出,而是当我单击容器 div 时退出。
最佳答案
试试这个...
$(function () {
$("#test").draggable({
handle: "#testheader",
containment: 'window'
});
$('#exit').click(function () {
$('#test').hide();
});
});
删除 });
上的 $('#exit')
看看这个 jSfiddle example
关于javascript - .hide() 隐藏容器 div 单击而不只是处理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15031508/