user3052997
user3052997

Reputation: 91

add link to jquery append

I'm trying to add a href link to jquery append. The link opens an ajax modal when clicked.

here's what I have

  $('<div/>').text(message.text).prepend($('<em/>')
  .text('Opponent: '+ opponentName + ',' + ' ' + 'Game amount: ' + message.amount + ' ' + 'tokens,' + ' ' + 'Game: ' + message.game + ' ' + '<a href="#" data-toggle="ajaxModal">accept</a>')).appendTo($('#pendingChallenges'));
        $('#pendingChallenges')[0].scrollTop =    $('    #pendingChallenges')[0].scrollHeight;

Upvotes: 0

Views: 95

Answers (1)

PSL
PSL

Reputation: 123749

You need to use html instead of text to have your html string to be represented as html instead of textcontent which is what happens when you use text.

$('<div/>').text(message.text).prepend($('<em/>')
   .html(...

Upvotes: 2

Related Questions