0

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;
3
  • To clarify you want your structure to look like this: <div><em>message.text</em>Opponent: opponentName, Game amount: amount tokens, Game: game<a>accept</a>? Commented Jan 3, 2014 at 21:36
  • @user1034372 Don't forget the closing </div>. :) Commented Jan 3, 2014 at 21:41
  • True! Also, I don't know what the #pendingChallenges is an id for. Commented Jan 3, 2014 at 21:43

1 Answer 1

2

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(...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.