[英]want to show and hide div with jquery
I am completely new to jquery, and don't understand it 100%. 我对jquery完全陌生,并且100%都不了解。 What I want is a div containing text or an image, and when you click on it, it will show another div.
我想要的是一个包含文本或图像的div,当您单击它时,它将显示另一个div。
HTML: HTML:
<div class="mytrigger">click here</div>
<div class="mycontent">show this when clicking on the above</div>
Jquery: jQuery:
<script>
$( ".mytrigger" ).click(function() {
$( ".mycontent" ).toggle( "slow", function() {
});
});
</script>
so, when you click on "mytrigger", it must show "mycontent. 因此,当您单击“ mytrigger”时,它必须显示“ mycontent。
Just leave the function inside your toggle-call away: 只需将函数保留在您的切换调用中即可:
$(function() {
$( ".mytrigger" ).click(function() {
$(".mycontent").toggle("slow");
});
});
See: http://jsfiddle.net/a8Np4/3/ 请参阅: http : //jsfiddle.net/a8Np4/3/
Edit: Wrapped in a DOM-Ready-Call 编辑:包裹在DOM就绪调用中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.