切换显示/隐藏div与按钮? [英] toggle show/hide div with button?
本文介绍了切换显示/隐藏div与按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< div id =newpost
解决方案
查看jQuery切换
HTML:
< div id ='content'> Hello World< / div>
< input type ='button'id ='hideshow'value ='hide / show'>
jQuery :
jQuery(document).ready(function(){
jQuery('#hideshow')。live('click',function(event){
jQuery('#content')。toggle('show');
});
});
对于jQuery 1.7和更新版本,使用
jQuery(document).ready(function(){
jQuery('#hideshow')。 ('#content')。toggle('show');
});
});
Hopefully this is an easy question. I have a div that I want to toggle hidden/shown with a button.
<div id="newpost">
解决方案Look at jQuery Toggle
HTML:
<div id='content'>Hello World</div> <input type='button' id='hideshow' value='hide/show'>
jQuery:
jQuery(document).ready(function(){ jQuery('#hideshow').live('click', function(event) { jQuery('#content').toggle('show'); }); });
For versions of jQuery 1.7 and newer use
jQuery(document).ready(function(){ jQuery('#hideshow').on('click', function(event) { jQuery('#content').toggle('show'); }); });
这篇关于切换显示/隐藏div与按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文