If you do not want to write it directly in the statement, then, yes. Create it, store it and then insert it.
var p = '<p>Hello world!</p>'
Note that this is an element, but not a jQuery object. Witness what happens when we do this...
To get the same effect as above, we still need the jQuery selector in the second statement.
Now if that is absorbed, we can go into your attempt, and get it working with jQuery magic.
$p = $('<p/>').text("Hello World!");
We have created an element node that is transient in memory until such time as the variable reference changes. Permanent if that variable is never changed. The node is an ojbect in memory, and not yet in the DOM. What's cool about it is that it is a sprite object, meaning we can move it around and modify it all we want during the session. It can be removed from the page and reinserted on the fly, at any time.
$p.text("The world is moving!");