Pathik Gandhi
Pathik Gandhi

Reputation: 1344

jQuery - can anybody help me...?

I'm using this code for append some code using jQuery but it won't work.

$('#'+DivId).append($(maincontent).fadeIn('slow'));

but if I use this then it works perfectly

$('#'+DivId).html(maincontent);

Does anybody know what is the problem with append()?

Thanks

Upvotes: 1

Views: 61

Answers (2)

James Allardice
James Allardice

Reputation: 165971

Your code should work fine. It may be that you need to run inside a $(document).ready function:

$(document).ready(function() {
    var maincontent = "<p>Just some text to test...</p>";
    $("#test").append($(maincontent).fadeIn('slow'));
});

You can see the above code running here.

Upvotes: 0

genesis
genesis

Reputation: 50976

use this

$("#your_div").fadeIn('slow');
$('#'+DivId).append(maincontent);

Upvotes: 1

Related Questions