Welcome to jQuery quickie, and here is where I share some of the jQuery goodness that is in something I have done for a project. Then again, there are still going to be those days where I just want to try something out to see if I can do it and post it. Either way, you’re going to be getting something to use and take away the need for a plugin in your project one at a time.

Today’s quickie is going to be more of a did you know about how this is suppose to be used post. This is something new that you’ll see more coming in the future because in the dev world there is too many ways that we all can do something. To start this off, we’re looking at .html().

So for as long as I can remember I always thought that .html() was more of a chaining function, meaning you can just keep adding and adding to it. See below example.

[code lang=”js”]$(‘#title’).html($(‘aside’).text() + $(‘#right’).text() );[/code]

Of course the above selection isn’t a real world example, but it does highlight how I was wrongly using the .html() function in the rare times I actually needed it. The problem is in a real world example of using the jQuery function like this will result in a console error. So how is it suppose to be done? Well, here is the answer.

[code lang=”js”]$(‘#title’).html(function(){$(‘aside’).text() + $(‘#right’).text()});[/code]