I want to use jquery to build HTML like this:
Track Nam
There are several ways to do it, including (but not limited to):
// one big string
$('Track Name')
// create then append() the span
$('').attr("href","#")
.append('Track Name');
// create then set all of its contents with html()
$('').attr("href","#")
.html('Track Name');
// append spans created earlier:
var spans = $('Track Name');
var a = $('').append(spans);
Note that .html()
replaces any and all existing contents, while .append()
adds to the end. So given that you have two span elements in your example you could create those independently and append them one at a time:
$('').append('')
.append('Track Name');