如何使用 javascript/jquery 添加诸如最小化、最大化和关闭 div 之类的按钮?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20812753/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 19:21:32  来源:igfitidea点击:

How to add buttons like minimize,maximize and close to a div using javascript/jquery?

javascriptjqueryhtml

提问by Pragmatic Programmer

How to add buttons like minimize,maximize and close to a div using javascript/jquery? Please provide easier solution..

如何使用 javascript/jquery 添加诸如最小化、最大化和关闭 div 之类的按钮?请提供更简单的解决方案..

回答by Sridhar R

Try like this

像这样尝试

<div class="content">Some content!</div>

<button class="btn-minimize"></button>

Script

脚本

$(".btn-minimize").click(function(){
    $(this).toggleClass('btn-plus');
    $(".content").slideToggle();
  });

DEMO

演示