如何解决JQuery Resizable停止后如何获取宽度和高度?
| 使用jQuery UI Resizable重新调整div / element的大小后,是否有任何方法来获取它的大小?解决方法
$( \".selector\" ).resizable({
stop: function(event,ui) {
var width = ui.size.width;
var height = ui.size.height;
}
});
,$( \"#resizable\" ).resizable({
stop: function( event,ui ) {
height = $(\"#resizable\").height();
width = $(\"#resizable\").width();
}
});
,您可以始终在jQuery元素上使用height()和width()
,在可调整大小的初始化对象中,为the2 define事件定义一个处理程序,然后在其中检查大小。
$( \".selector\" ).resizable({
stop: function(event,ui) { ... }
// not 100% sure it\'ll be event.target that you want,// inspect in console to double-check
var width = $(event.target).width();
var height = $(event.target).height();
// do stuff with width & height
});
,为\'stop \'事件添加一个处理程序。
$(\"#element\").resizable({
stop: function(event,ui) {
var x = $(event.target).width();
...
}
});
您还可以绑定到resizestop。
http://jqueryui.com/demos/resizable/#event-stop
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。