Charles Michel Charles Michel - 4 months ago 6x
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.



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!