I created a div element using php echo
*//some html code*
*<?php echo "<div id = "randomDiv"></div>" ?>
<script>
document.getElementById("randomDiv").innerHTML = "Hey";
</script>*
but this does not manipulate the innerHTML of the div. Any ideas how to resolve this?
Double quote for div id
makes it invalid. Try changing the quote to single quote:
<?php echo "<div id='randomDiv'></div>"; ?>
<script>
document.getElementById("randomDiv").innerHTML = "Hey";
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.