0

I'm trying to make a text into a link in my Javascript code. This should work but it doesn't.

    var strLink = <a href="xxx" style= "text-decoration:none; color:#fff;">"mysite.com" </a>; 
        var cb_header = chatbox.find('.imjs-header');
        cb_header.html(cb_header.html().replace('{username}', strLink));

I have a variable called username and it is a string. That is the string that used to replace {username}. Maybe I can use jquery? I can't seem to get it a link though. Any pointers in the right direction are greatly appreciated.

Thank you, Arjun

1
  • your syntax is wrong; a string variable (strLink) needs to be enclosed in quote (") chars. also you'll have to escape actual quotes inside the string Commented Nov 17, 2013 at 0:33

2 Answers 2

1

var strLink = '<a href="xxx" style= "text-decoration:none; color:#fff;">"mysite.com" </a>';

Sign up to request clarification or add additional context in comments.

1 Comment

You'll need a closing ' after </a>. Also Arjun, you won't need quotes around mysite.com unless you want them to actually show up on the page.
0

Try this:

var strLink = '<a href="xxx" style= "text-decoration:none; color:#fff;">"mysite.com" </a>';

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.