How to access payload in mustache template under script tag

#1

Hello,
I am using the mustache template. In body of html file ,I am using div tag with id="myMsg" to print the value of payload using {{payload}}.I want to access this value into the script tag. Pls let me know how to do it. HTML file-

<html>
 <head>
<script type="text/javascript">
console.log("1");
var myMsgValue=document.getElementById("myMsg");
console.log(myMsgValue);
</script>
 </head>
 <body>
    <div id="myMsg">{{ payload }}</div>
  </body>
</html>

Pls find below the json file-

[{"id":"3fbe188.79c4ee8","type":"tab","label":"TEST","disabled":false,"info":""},{"id":"f279086a.02503","type":"http in","z":"3fbe188.79c4ee8","name":"","url":"/tpl","method":"get","upload":false,"swaggerDoc":"","x":120,"y":200,"wires":[["21d1aac4.bbf12e"]]},{"id":"cb5e054c.38fc7","type":"template","z":"3fbe188.79c4ee8","name":"page","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n <head>\n<script>\nconsole.log(\"1\");\nvar myMsgValue=document.getElementById('myMsg');\nconsole.log(myMsgValue);\n</script>\n </head>\n <body>\n <div id=\"myMsg\">{{ payload }}</div>\n </body>\n</html>","x":630,"y":200,"wires":[["1b36a6f3.c9cb61","fcb90402.2dbe9"]]},{"id":"1b36a6f3.c9cb61","type":"http response","z":"3fbe188.79c4ee8","name":"","statusCode":"","headers":{},"x":830,"y":200,"wires":[]},{"id":"21d1aac4.bbf12e","type":"function","z":"3fbe188.79c4ee8","name":"","func":"msg.payload = 'Rajesh';\nmsg.location = 'Noida';\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":200,"wires":[["cb5e054c.38fc7","7e5f25ea.59d094"]]},{"id":"7e5f25ea.59d094","type":"debug","z":"3fbe188.79c4ee8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":690,"y":120,"wires":[]},{"id":"fcb90402.2dbe9","type":"debug","z":"3fbe188.79c4ee8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":870,"y":140,"wires":[]}]

#2

Please read this post about sharing code: How to share code or flow json

Currently we cannot see any of the html in your post. Go back and edit it as described in that linked post.