0

After writing the html expression as a string in javascript and append it, the quotes get mixed up.

var string ="<a href='javascript:;' onclick='toastr.clear('$(this).closest('.toast-bottom-left')');' class='ml-2' id='approve_button'>Kabul Et</a>"

After append it takes the following state.

<a href="javascript:;" onclick="toastr.clear(" $(this).closest('.toast-bottom-left')');'="" class="ml-2" id="approve_button">Kabul Et</a>
  • 1
    If it is supported in your browser, use [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) with backticks. You don't have to worry about escaping quotes – adiga Nov 10 '20 at 11:49
  • Use this and let me know if it works `var string ="Kabul Et"` – Vlad S Nov 10 '20 at 11:51

0 Answers0