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     

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...