jquery smooth effect
I want to make something similar with this
When you click on "description" text appears. I want to create this effect with jQuery, how can I make this?
You can use fadeTo function in jquery
Perhaps a fadeToggle() ?
<a href="#" id="appear">Clicky</a>
<p class="textTo" style="display: none;">Hello World!</p>
<script type="text/javascript">
$("#appear").click(function() {
$(".textTo").fadeToggle();
});
</script>
check out the working fiddle: http://jsfiddle.net/vfcp4/
and the api:
http://api.jquery.com/fadeToggle/
the api shows a bit more.
for example there are some parameters to pass controlling animation speed, type, etc.
You can do it like this:
<div id="description"> Description (click here to show) </div>
<div id="textToShow" style="display:none"> Now I'm visible ! </div>
$(document).ready(function(){
$("#description").click(function(){
$("#textToShow").fadeIn("slow");
});
});
You can use an image or any element to be shown. Hope this helps. Cheers
精彩评论