-3

I would like to change the following line:
$("<ul><li><a href="+url">"+displayName + "</a>"+"<br>"+description+"</br></li></ul>".appendTo(".results")

into the next string:
$("<ul><li><a href={0}> {1}" + "</a>"+"<br>"+description+"</br></li></ul>",{0:url, 1:displayName}.appendTo(".results").

however, instead of displayName i get 1. please help to fix this As you can see i've tried to write it like in c#

1 Answers1

1

Using ES6 string interpolation, it would look like this:

$(`
  <ul>
    <li>
      <a href=${url}> ${displayName}</a>
      <br>${description}</br>
    </li>
  </ul>
`).appendTo(".results");

Notice the back-ticks instead of double-quotes.

T Porter
  • 1,162
  • 7
  • 15