I'm getting a javascript error from my console that reads:
Uncaught TypeError: Cannot read property 'style' of null
Does anyone know whats wrong?
Code (JS):
<script>
function select()
{
document.getElementById('#iframetest').style.display='block';
}
</script>
Code (HTML):
<iframe src="localhost/createaclass" id="iframetest"></iframe>
<div class="b" onclick="select()">
Don't place the hash in id (#):
document.getElementById('iframetest')
As per your comment, you can do like this:
function select()
{
document.getElementById('iframetest').style.display = 'block' ? 'none' : 'block';
}
Move your JS below the HTML.
<iframe src="localhost/createaclass" id="iframetest"></iframe>
<div class="b" onclick="select()">
<script>
function select()
{
document.getElementById('#iframetest').style.display='block';
}
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With