Rashid
Rashid

Reputation: 1384

How to include fadein effect to .html() method in JQuery?

I am changing a div's inner html by jquery's .html() method

$("#model_desc_inner").html(current_text).fadeIn("slow");

I want to apply some effect on changing of new text. For this purpose I included .fadeIn("slow") method at the end.
But it is not including fadeIn effect on changing of new text.
Please give me some solution.
Thank you in advance.

Upvotes: 1

Views: 121

Answers (2)

Banik
Banik

Reputation: 921

you can try this

$("#model_desc_inner").fadeOut(function() {
   $(this).html(current_text).fadeIn("slow");
});

Upvotes: 1

Ram
Ram

Reputation: 144699

The method name is fadeIn not fadein. JavaScript is case-sensitive! Also if the "#model_desc_inner" element is already visible, fadeIn effectively doesn't do anything. You should at first .hide() the element.

$("#model_desc_inner").hide().html(current_text).fadeIn("slow");

Upvotes: 2

Related Questions