Question

I want to know if I can get the size of div at the moment of the sizing it.

I'm using the jquery 1.10.2 and used a DIV to be resizable but I saw that I have the events start and stop which allows me to get the div size just when start to click or when stop to click but I want to get the div sizes in real time when the div is being sizing and write them (height and width) into a textbox or div or whatever like this.

<script type="text/javascript">
    $(function () {
        $("#divResizable").resizable({
            start: function (event, ui) {
                var width = ui.size.width;
                var height = ui.size.height;
                //alert(width);
                document.getElementById("divText").innerHTML = width;
            }
        });
    });
</script>
Was it helpful?

Solution

You can handle the resize event like this (note I am assuming you are using jquery UI too ):

<script type="text/javascript">
    $(function () {
        $("#divResizable").resizable({
            resize: function (event, ui) {
                var width = ui.size.width;
                var height = ui.size.height;
                $("#divText").html(width + ', ' + height);
            }
        });
    });
</script>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top