i am new in php. i just want to make a button for hide or un-hide the div
and i placed a code in php block
when i write code in php block.button not work properly;
when i code it outside the php block then it run.
why it not run in php block?
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
echo"<button onclick='myFunction('confession13')'>Comment</button>
<div id='confession13'>
<p>hlo world</p>
</div>";
?>
<script type="text/javascript">
function myFunction(p1)
{
console.log(p1);
var x = document.getElementById(p1);
if (x.style.display === "none")
{
x.style.display = "block";
}
else {
x.style.display = "none";
}
}
</script>
</body>
</html>