> I do not understand why > > $('#content').empty().append("<b>hello</b>"); > > works, and this works > > $('#content').empty().append(makeContent()); > > function makeContent(){ > return "<b>hello</b>"; > };
That works because it is exactly the same as this code: function makeContent(){ return "<b>hello</b>"; } var content = makeContent(); $('#content').empty().append(content); IOW, the () after makeContent cause that function to be called *before* the append() call, and makeContent's *return value* is passed into append(). > and this > > $('#content').empty().append( function() { return "<b>hello</b>" } ); > > does not produce any output? That doesn't work because you are not calling the function any more, but merely passing a *reference* to the function, i.e. the function itself, into append(). append() doesn't expect to be passed a function. IOW, that code is the same as: function makeContent(){ return "<b>hello</b>"; } $('#content').empty().append(makeContent); Without the parens, makeContent is not called. -Mike