Clyde Clyde - 2 years ago 137
Javascript Question

Get size of resizable div

I have this resizable div using jQueryUI. I need to get it's size every time it is resized. My code is below:

$(".resizeable_div").on("resize", function(event, ui) {
var h = $("#h").height();
var w = $("#w").width();

The code above only gets the initial size of the div. Every time I resize the div the height and width doesn't change. Any help would be much appreciated.

Answer Source

The resize event is only raised by the window. You need to hook to the stop event in the resizeable plugin, and use the ui helper to get the size. Try this:

    stop: function(event, ui) {
        var w = ui.size.width;
        var h = ui.size.height;

        // do stuff...
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download