简体   繁体   English

jQuery-UI对话框当前的高度和宽度

[英]jQuery-UI dialog current height and width

I want to show the current height and width of jQuery-UI dialog in real time inside dialog box. 我想在对话框中实时显示jQuery-UI对话框的当前高度和宽度。 How can I do the same. 我该怎么做。 I mean if I increase the height by dragging then current height will be updated. 我的意思是,如果我通过拖动来增加高度,那么当前高度将被更新。

Thanks 谢谢

Try this out: http://jsfiddle.net/bryanjamesross/ngrkf/ 试试看: http : //jsfiddle.net/bryanjamesross/ngrkf/

Should be enough to get you started. 应该足以让您入门。 What you're looking for mainly is the resize event of the jQueryUI dialog. 您主要要查找的是jQueryUI对话框的resize事件。

Check docs here: http://jqueryui.com/demos/dialog/#event-resize 在此处查看文档: http : //jqueryui.com/demos/dialog/#event-resize


HTML: HTML:

<div id="dlg">
    Width: <span id="w"></span><br />
    Height: <span id="h"></span>
</div>

JavaScript: JavaScript的:

$('#dlg').dialog({
    resize: function(e,ui) {
        $('#w').text(Math.round(ui.size.width));
        $('#h').text(Math.round(ui.size.height));
    } 
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM