Append an element with fade in effect [jQuery]

var html = "<div id='blah'>Hello stuff here</div>"


This doesn't seem to work.

I just want a cool effect when the content gets appended.

Note: I want just the new "blah" div to fade in, not the entire "mycontent".



Adding a little more info:

jQuery implements "method chaining", which means you can chain method calls on the same element. In the first case:


you would be applying the fadeIn call to the object which is target of the method chain, in this case #mycontent. Not what you want.

In @icktoofay's (great) answer you have:


This basically means, create the html, set it as hidden by default, append it to #mycontent and then fade it in. The target of the method chain now is hmtl instead of #mycontent.

This also works



Need Your Help

AngularJS conditional ng-disabled does not re-enable

javascript angularjs angularjs-scope

Given a conditionally disabled text input field using ng-disabled="truthy_scope_variable", AngularJS disables the field the first time the scope variable is falsified, but does not enable it on