Charles Michel Charles Michel - 1 year ago 70
jQuery Question

html </script> is not placing inside a single quotes

In my program i wanted to append block of html code using js append statement as follows

$("#day_s_add{{ $row['hdr_id'] }}").click(function () {
$("#day_s{{ $row['hdr_id'] }}").append('<script> $(function() { $( "#datepicker{{ $row["hdr_id"] }}" ).datepicker({ dateFormat : "dd-mm-yy", }); });</script>');

here the
tag inside single quotes on append statement is not working :( how to make the closing script tag as a normal string.


Answer Source

Did you try escaping the closing tag? You also missing closing )};.


$("#day_s_add{{ $row['hdr_id'] }}").click(function () {
    var str = '<script>$(function() {$( "#datepicker{{ $row["hdr_id"] }}" )' +
    '.datepicker({   dateFormat : "dd-mm-yy",  }); });\</script>';
    $("#day_s{{ $row['hdr_id'] }}").append(str);


And please respect peoples which will help you, format your sample!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download