-1

I'm stucked in a simple variable, what i want to achieve is to have link text as variable. my code:

 var ReadMore = myvar;

          $(this).empty().html(subStr);
          $(this).append(' <a href="javascript:void(0);" class="linkReadMore">MY VARIABLE HERE</a>')

i've tried in many ways but i'm doing something wrong for sure, can someone tell me what i'm doing wrong?

MarcoWriteCode
  • 113
  • 1
  • 5
  • Dear can you please share the full information or code. – Muhammad Asif May 26 '21 at 07:25
  • _"i've tried in many ways"_ - Why is there none of them in your question? – Andreas May 26 '21 at 07:28
  • String concatenation is part of every JavaScript tutorial out there -> [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) – Andreas May 26 '21 at 07:29
  • Does this answer your question? [How do I put variables inside javascript strings?](https://stackoverflow.com/questions/7790811/how-do-i-put-variables-inside-javascript-strings) – Andreas May 26 '21 at 07:30
  • Possible dupe: [How to interpolate variables in strings in JavaScript, without concatenation?](https://stackoverflow.com/questions/3304014/how-to-interpolate-variables-in-strings-in-javascript-without-concatenation) – Andreas May 26 '21 at 07:30

1 Answers1

0

I think you have not concatenate the variable inside anchor tag.

var myvar = "ReadMore";

You have to concatenate your variable like this

$(this).append('<a href="javascript:void(0);" class="linkReadMore">'+myvar+'</a>');
Lokesh Suman
  • 493
  • 5
  • 14