Answers for "Uncaught TypeError: Cannot read property 'appendChild' of null"

1

Cannot read property 'appendChild' of null

$( document ).ready(function() {
	// maybe the element with the id has not yet loaded
});
Posted by: Guest on July-11-2021
0

Uncaught TypeError: Cannot read property 'appendChild' of null

<!DOCTYPE html>
<html>
<head>
	<title>space</title>
	<style type="text/css">
		#board{
			position: relative;
			height: 450px;
			width: 450px;
			margin: 40px auto;
			border: 2px solid #fff;
			background: #000;
		}
		#jet{
			position: absolute;
			width: 45px;
			height: 40px;
			background: #45a76a;
			background-size: contain;
			background-repeat: no-repeat;
			left: 50%;
			bottom: 0px;
		}
		.rockes{
			position: absolute;
			top: 0px;
			width: 50px;
			height:50px;
			background: #a76f45;
			background-size: contain;
			background-repeat: no-repeat;
		}
	</style>
</head>
<body>

<div id="board" defer>
	<div class="rockes"></div>
	<div id="jet"></div>
</div>



<script type="text/javascript">
	var jet =document.getElementById('#jet');
	var board =document.getElementById('#board');
	

	window.onkeydown = function(e){
		var jet =document.querySelector('#jet');
			jetX = parseInt(window.getComputedStyle(jet,null).getPropertyValue('left'));

		if( e.keyCode == 39 && jetX < 400){
			var jet =document.querySelector('#jet');
			jetX = parseInt(window.getComputedStyle(jet,null).getPropertyValue('left'));
			jet.style.left = jetX + 10 + "px";
		}
		if( e.keyCode == 37 && jetX > 5){
			var jet =document.querySelector('#jet');
			jetX = parseInt(window.getComputedStyle(jet,null).getPropertyValue('left'));
			jet.style.left = jetX - 10 + "px";
		}

	}

var generaterRocks = setInterval(() => {

	var board =document.getElementById("#board");	
	const rock =document.createElement("div");
	rock.classList.add("rocks");
	var rockleft =parseInt(window.getComputedStyle(rock,null).getPropertyValue('left'));
	rock.style.left =Math.floor(Math.random()*460) + "px";

	board.appendChild(rock);
},1500);


</script>
</body>
</html>
Posted by: Guest on October-07-2021
0

Uncaught TypeError: Cannot read property 'appendChild' of null

<script type="text/javascript">
	var jet =document.getElementById('#jet');
	var board =document.getElementById('#board');
	

	window.onkeydown = function(e){
		var jet =document.querySelector('#jet');
			jetX = parseInt(window.getComputedStyle(jet,null).getPropertyValue('left'));

		if( e.keyCode == 39 && jetX < 400){
			var jet =document.querySelector('#jet');
			jetX = parseInt(window.getComputedStyle(jet,null).getPropertyValue('left'));
			jet.style.left = jetX + 10 + "px";
		}
		if( e.keyCode == 37 && jetX > 5){
			var jet =document.querySelector('#jet');
			jetX = parseInt(window.getComputedStyle(jet,null).getPropertyValue('left'));
			jet.style.left = jetX - 10 + "px";
		}

	}

var generaterRocks = setInterval(() => {

	var board =document.getElementById("#board");	
	const rock =document.createElement("div");
	rock.classList.add("rocks");
	var rockleft =parseInt(window.getComputedStyle(rock,null).getPropertyValue('left'));
	rock.style.left =Math.floor(Math.random()*460) + "px";

	board.appendChild(rock);
},1500);


</script>
Posted by: Guest on October-07-2021
0

Uncaught TypeError: Cannot read property '_calendar' of undefined

you just passed wrong parameter value inside date parameter
Posted by: Guest on December-19-2020

Code answers related to "Uncaught TypeError: Cannot read property 'appendChild' of null"

Code answers related to "Javascript"

Browse Popular Code Answers by Language