I am completely new to jquery, and don't understand it 100%. What I want is a div containing text or an image, and when you click on it, it will show another div.
HTML:
<div class="mytrigger">click here</div>
<div class="mycontent">show this when clicking on the above</div>
Jquery:
<script>
$( ".mytrigger" ).click(function() {
$( ".mycontent" ).toggle( "slow", function() {
});
});
</script>
so, when you click on "mytrigger", it must show "mycontent.
Just leave the function inside your toggle-call away:
$(function() {
$( ".mytrigger" ).click(function() {
$(".mycontent").toggle("slow");
});
});
See: http://jsfiddle.net/a8Np4/3/
Edit: Wrapped in a DOM-Ready-Call
It is working fine now
You might need to put your Jquery inside
$(document).ready(function()
{
//Your code here
}
Also just hide the second div initially adding a display:none
style to mycontent
class.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.