[英]jQuery resizable handles visible when clicked and hide when clicked elsewhere
I'm using jQuery's resizable handles and I use autohide: true
to hide the handles. 我正在使用jQuery的可调整大小的句柄,并且使用了autohide: true
来隐藏句柄。
My question is how can I make the handles visible when the relevant div is clicked and turn the handles off when clicked somewhere out of the relevant div. 我的问题是,如何在单击相关div时使手柄可见,而在相关div之外的某处单击时如何关闭手柄。
jQuery('#dragDiv').resizable({
containment: $('#wrapper'),
handles: 'ne, se, sw, nw',
//autoHide: true
});
How about adding a click handler to the document to add/remove a focus class which you can use to control the style/visibility of the handles? 如何在文档中添加单击处理程序以添加/删除焦点类,您可以使用它来控制手柄的样式/可见性?
$(document).on('click', function(e) {
$('.resizable').removeClass('focus');
$resizable = $(e.target).closest('.resizable');
if ($resizable.length) {
$resizable.addClass('focus');
}
});
http://jsbin.com/rocepamiwu/1/edit?html,css,js,output http://jsbin.com/rocepamiwu/1/edit?html,css,js,output
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.