Converting String to HTML - string to “ a href” element

前端 未结 3 1883
星月不相逢
星月不相逢 2021-01-18 16:10

Hello I am having some trouble getting some HTML links to add to my HTML page. I have tried searching around but nothing has helped thus far.

My page will initially

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-18 16:28

    As Just code points out, you want to use the html method, not the text method. html() is jQuery's wrapper for innerHTML, which injects the string as html.

    Here is a jsFiddle showing the difference:

    http://jsfiddle.net/89nxt/

    $("#teamRosterHtml").html("John Frank");
    $("#teamRosterText").text("John Frank");
    

提交回复
热议问题