Zuhair Taha
Zuhair Taha

Reputation: 3032

How to fadeOut with jQuery?

I have this function in javascript:

function hid(id) {
    var x = document.getElementById("desc_div" + id).style.display = "none";
}

and I hope to use fadeOut effect instead of display = "none" by using jQuery

How can I do that?

Upvotes: 1

Views: 195

Answers (5)

Shyju
Shyju

Reputation: 218732

 function hid(id){
   $("#desc_div"+id).fadeOut("slow");
 }

See .fadeOut().

Upvotes: 2

DarkAjax
DarkAjax

Reputation: 16223

You can do it like this:

function hid(id){
    $('#'+id).fadeOut();
}

Also, keep in mind you can use fadeOut like: fadeOut( [duration] [, callback] ), in case you want to specify the duration in milliseconds, and a function to be executed after the animation is over, or .fadeOut( [duration] [, easing] [, callback] ) in case you want to specify an easing function as well.

Upvotes: 0

DG3
DG3

Reputation: 5298

$("#desc_div" + id).fadeOut();

Upvotes: 1

nathanjosiah
nathanjosiah

Reputation: 4459

function hid(id){
    jQuery("#desc_div"+id).fadeTo(0);
}

Upvotes: 0

Related Questions