开发者

How to get width and height after JQuery Resizable stops?

Is there any way of getting the size of a div/element after it has 开发者_如何学JAVAbeen resized with JQuery UI Resizable?


$( ".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(); 

    } 
});


you can always use height() and width() on a jQuery element


In your init object for the resizables, define a hander for the resizestop event, where you can then check the size.

$( ".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
});


Add a handler for the 'stop' event.

$("#element").resizable({
   stop: function(event, ui) {
      var x = $(event.target).width();
      ...
   }
});

You can also bind to resizestop.

http://jqueryui.com/demos/resizable/#event-stop

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜