Quite the opposite – in the first variant, you’re inefficiently querying the DOM twice and create two jQuery objects, where in the second you’re creating only one. Chainability is a very important feature of jQuery, and where you can’t chain those methods directly (e.g. because the CSS has to applied later at some point), one should cache the resulting object like e.g.
$error = $('#error').html('Please enter all the details.')
// Then, later
if (someErrorOccurred) {
$error.css('display', 'block')
}