nifCody
nifCody

Reputation: 2444

getting resized image new width and height

On resize i need to get the new width and height of the div, I have doing this script using jquery-ui and jquery but it fail

$(this).resizable(function(){
            console.log("Height: " + $(this).height());
            console.log("Width: " + $(this).width());
        }); 

help to find how to correct this error.

Upvotes: 0

Views: 286

Answers (3)

Gabriel Garcia
Gabriel Garcia

Reputation: 11

This is how I've been doing it:

 <script>
    function resizeDiv() {
        vpw = $(window).width();
        vph = $(window).height();
        console.log("Width: " + vpw);
        console.log("Height: " + vph);
    }

    window.onresize = function(event) {
        resizeDiv();
    }
</script>

Upvotes: 1

mplungjan
mplungjan

Reputation: 177692

$(this).resizable()
       .on("resize", function() {
        console.log("Height: " + $(this).height());
        console.log("Width: " + $(this).width());
});

or

$(this).resizable({
  resize: function(event, ui ) {
        console.log("Height: " + ui.height());
        console.log("Width: " + ui.width());
  }
});

Upvotes: 2

dam660
dam660

Reputation: 79

Have you tried this ?

$(this).on('resize',function(){ // Your stuff goes here });

Upvotes: 1

Related Questions