开发者

jquery smooth effect

开发者 https://www.devze.com 2023-03-03 09:40 出处:网络
开发者_开发问答I want to make something similar with this When you click on \"description\" text appears.
开发者_开发问答

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

0

精彩评论

暂无评论...
验证码 换一张
取 消