I am having the following code in my JS.
$('#ytResultsList').append('<li><a href="https://www.youtube.com/watch?v="' + item.id.videoId + '></a></li>');
As you can see from the above code, in HTML the result is like below.
<li><a href="https://www.youtube.com/watch?v=" bruvbiwlwfi=""></a></li>
I want the URL to be like below in HTML.
"https://www.youtube.com/watch?v=bruvbiwlwfi"
How can I do this in Javascript?
The issue is because you are formatting your href
incorrectly. You need to move your closing "
to after the variable like this:
$('#ytResultsList').append('<li><a href="https://www.youtube.com/watch?v=' + item.id.videoId + '"></a></li>');