如何使用 jquery 调整文本框大小并获取 div 元素内的尺寸
我有一个可以拖动的 div 元素,并且该 div 元素内有一个文本框,当我自动拖动 div 元素时,文本框大小应随 div 一起增加。我需要获取文本框的 X 和 Y 位置,那么如何做我这样做?
这就是我现在所拥有的:
这是我的ode:
<div class="demo">
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"></asp:TextBox>
</div>
这是我的拖动脚本:
<script>
$(function () {
$('.demo')
.draggable()
.resizable();
});
</script>
I have a div element which can be draggable and I have a textbox inside that div element and when I drag the div element automatically the textbox size should increase along with the div.And I need to get the textbox X and Y positions so how do I do that?
This is what I have now:
Here is my ode:
<div class="demo">
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"></asp:TextBox>
</div>
This is my script for dragging:
<script>
$(function () {
$('.demo')
.draggable()
.resizable();
});
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据规范,
textarea
应按行和列指定,但您仍然可以使用 CSS 对其进行样式设置:请参阅 这里。在 Firefox、Chrome 中测试。
另外,如果您需要获取 X 和 Y 坐标,draggable 有一个可以绑定到的
stop
方法:A
textarea
should be specified in terms of rows and columns, according to the specs, but you can still style them with CSS:See here. Tested in Firefox, Chrome.
Also, if you need to get the X and Y coordinates, draggable has a
stop
method which you can bind to:这就是你想要的吗?
http://jsfiddle.net/gmrcn/
编辑:
http://jsfiddle.net/gmrcn/2/
Is that what you want?
http://jsfiddle.net/gmrcn/
Edit:
http://jsfiddle.net/gmrcn/2/