Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用jQuery Resizeable获取端部大小调整后的宽度_Javascript_Php_Jquery_Css_Resize - Fatal编程技术网

Javascript 使用jQuery Resizeable获取端部大小调整后的宽度

Javascript 使用jQuery Resizeable获取端部大小调整后的宽度,javascript,php,jquery,css,resize,Javascript,Php,Jquery,Css,Resize,当我使用jQuery Resizeable调整div的宽度时,没有得到正确的宽度。 将宽度从250px调整为200px在jQuery中得到的宽度是250px。但背景色的位置是200px。我再次从200px调整到150px,得到的值是200px。为什么我有开始宽度位置。请帮助我获得结束宽度位置 请检查我的代码和下面的图片,并更正我 CSS #profile #graph #bar1 #bar1_slider { background: #1640c0; width: 250px; }

当我使用jQuery Resizeable调整div的宽度时,没有得到正确的宽度。 将宽度从250px调整为200px在jQuery中得到的宽度是250px。但背景色的位置是200px。我再次从200px调整到150px,得到的值是200px。为什么我有开始宽度位置。请帮助我获得结束宽度位置

请检查我的代码和下面的图片,并更正我

CSS

#profile #graph #bar1 #bar1_slider {
   background: #1640c0;
   width: 250px;
}
$( "#graph .slider" ).resizable({
        animateEasing: "easeOutBounce",
        helper: "ui-resizable-helper",
        animate: true,
        handles: 'w',
        maxWidth: 250,
        grid: [ 50, 10 ] ,
        stop: function( event, ui ) {
            /*graph = ui["size"]["width"] / 50;
            alert(graph);*/
             var graph1 = $("#bar1_slider").width() / 50;

             $.post("/graph", { graph1: graph1},
                    function (response) {
             });
        }
    });
JS

#profile #graph #bar1 #bar1_slider {
   background: #1640c0;
   width: 250px;
}
$( "#graph .slider" ).resizable({
        animateEasing: "easeOutBounce",
        helper: "ui-resizable-helper",
        animate: true,
        handles: 'w',
        maxWidth: 250,
        grid: [ 50, 10 ] ,
        stop: function( event, ui ) {
            /*graph = ui["size"]["width"] / 50;
            alert(graph);*/
             var graph1 = $("#bar1_slider").width() / 50;

             $.post("/graph", { graph1: graph1},
                    function (response) {
             });
        }
    });

问题在于动画。Jquery在完成动画之前返回宽度值,因此元素的宽度没有改变。您可以在延迟1秒后返回值


你试过ui.size.width吗?@sandepnayak,是的,我试过这个。但结果是samePlease,提供JSFIDLE。@alirezasafian,这是链接@samsamit works,请检查