微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – 如何在jQuery UI对话框上设置包含?

是否有可能将包含(限制在另一个元素的边界)添加到jQuery UI的 Dialog

解决方法

您可以定位对话框并对其应用包含.试试这个:
var container = $('.dialog-container'),dialog = $('.ui-dialog');
// get container top left corner locations
var cx1 = container.offset().left,cy1 = container.offset().top;
// get dialog size
var dw = dialog.outerWidth(),dh = dialog.outerHeight();
// get container bottom right location,then subtract the dialog size
var cx2 = container.width() + cx1 - dw,cy2 = container.height() + cy1 - dh;
dialog.draggable( "option","containment",[cx1,cy1,cx2,cy2] );

编辑:我为你设置了a demo.Edit2:更改为使用对话框outerWidth& outerHeight

原文地址:https://www.jb51.cc/jquery/154906.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐