Jquery 滑动切换使我的文本区域向下跳

发布于 2024-12-14 20:09:56 字数 1094 浏览 4 评论 0原文

我正在使用这个 jQuery 插件: http://api.jquery.com/slideToggle/

我有这个代码:

<div id=panel><form action="postit.php" method="get" name="post" style = "margin-left:40px;">
<textarea required cols="35" rows="5" name="status" class="resizable" id = "statuses"></textarea>
<input type="submit" name="submit" value="FOO!"/>
</form></div>
<p class="slide"><a href="#" class="btn-slide">FOO</a></p>

基本上,这段代码意味着面板应该向下滑动,但是当我运行它时,div 平滑地向下滑动,但 textarea 运行良好,然后突然跳到顶部。

我该怎么解决这个问题,是 api 中的错误,还是我的代码中有问题?

谢谢,我已经尽力说得尽可能清楚了。

这是文本区域的 css,以防万一这可能导致问题,抱歉,如果这无关紧要,但有人也可能遇到此问题。

可调整大小的文本区域文本区域{ 显示:块; 下边距:0pt; 高度:20%; 宽度:90%; }

编辑:这是 javascript(抱歉):

$(".btn-slide").click(function(){
    $('textarea.resizable:not(.processed)').TextAreaResizer();
    $("#panel").slideToggle("slow");
    $(this).toggleClass("active"); return false;
});

I am using this jQuery plugin: http://api.jquery.com/slideToggle/

I have this code:

<div id=panel><form action="postit.php" method="get" name="post" style = "margin-left:40px;">
<textarea required cols="35" rows="5" name="status" class="resizable" id = "statuses"></textarea>
<input type="submit" name="submit" value="FOO!"/>
</form></div>
<p class="slide"><a href="#" class="btn-slide">FOO</a></p>

Basically, this code means that the panel should slide down, but when I run it, the div goes down smoothly, but the textarea goes well, then suddenly jumps up to the top.

What can I do to solve this, is it a bug in the api, or something wrong in my code?

Thanks, I have tried to be as clear as possible.

Here is the css for the textarea, in case that might be causing the problem, sorry if this is irrelevant, but someone might have this problem too.

resizable-textarea textarea {
display:block;
margin-bottom:0pt;
height: 20%;
width:90%;
}

EDIT: Here is the javascript(sorry):

$(".btn-slide").click(function(){
    $('textarea.resizable:not(.processed)').TextAreaResizer();
    $("#panel").slideToggle("slow");
    $(this).toggleClass("active"); return false;
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诠释孤独 2024-12-21 20:09:56

对我来说效果很好: http://jsfiddle.net/SHKNQ/

似乎 TextAreaResizer 存在问题使其滑落下来。请注意,在我的小提琴中,我已禁用它并且它工作正常。如果您包括 TextAreaResizer 我可以找到解决方案。

Works fine for me: http://jsfiddle.net/SHKNQ/

It seems that there is a problem TextAreaResizer which makes it slide back down. Notice in my fiddle I've disabled it and its working fine. If you include TextAreaResizer I can find a solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文