html - 使用 .slideDown Jquery 函数后如何保持我的部分打开?
问题描述
我试图让这个功能向下滑动并保持向下,但它一直向上滑动。
$('.call-to-action').on('click', function() {
if ($('#new-tweet').is(':hidden')) {
($('#new-tweet').slideDown());
} else {
($('#new-tweet').slideUp());
}
});
#new-tweet {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section id="new-tweet">
<h2>Compose Tweet</h2>
<form id="tweet-form" method="POST" action="/tweets">
<label for="tweet-text"></label>
//text area id="tweet=text" has no relevant css classes applied to it (just background color)
<textarea id="tweet-text" name="text" placeholder="What are you humming about?"></textarea>
<div class="button-count">
<button type="submit" class="submit-tweeet">Tweet</button>
<output name="counter" id="tx-counter" class="counter" for="tweet-text"></output>
</div>
</form>
</section>
任何帮助表示赞赏,谢谢。
解决方案
I think you should use toggle would be more reasonable
$('.call-to-action').on('click', function() {
$('#new-tweet').stop().toggle('slow');
});
推荐阅读
- c# - 配置代码清理配置文件以删除对象初始值设定项构造函数括号
- http - 亚马逊 MWS SubmitFeed _UPLOAD_VAT_INVOICE_ 元数据
- java - 转出基于文本字段的搜索栏
- powershell - 无法将变量解析到 ForEach($Servers 中的 $Server)循环中?
- php - 复杂对象的基于 PHP 条件的 JSON 输出
- android - 单击导航图的后退按钮时如何显示吐司
- php - Shopware 6:如何在管理模块的 Twig 模板中访问配置参数
- python - 列出我的子组中的所有工人
- laravel - Laravel 5.6 Flash Messages 必须自动关闭
- angular - 角度的动态嵌套菜单