Jump to content

[object HTMLDivElement]

Go to solution Solved by fizzlesticks,

In the toets function you are using a global "output" variable that already has a div element in it, you should declare a local variable to build the string by adding

var output = "";

to the top of the function.

Which webpage? And which browser do you use?

Everything that's in my PC and on my desk

Intel Core i5 4670K | MSI Z87-G45 Gaming | Corsair Vengeance LP 16GB RAM | MSI GTX 770 Gaming 2GB | Corsair Obsidian 450D | Intel 530 Series 240GB SSD | Toshiba 1TB HDD | Corsair CX750M  | Scythe Mugen 4 PCGH Edition | NZXT Hue RGB Leds | 2x Corsair AF140 Quiet Edition | Corsair AF120 Performance Edition | Nanoxia Frontpanel Extension Red | AOC G2770PQU | CM Storm Quickfire Ultimate MX Brown | Corsair Vengeance M65 FPS | Corsair Vengeance 1500

 

 

Link to comment
https://linustechtips.com/topic/293402-object-htmldivelement/#findComment-3984039
Share on other sites

Link to post
Share on other sites

This is showing on the webpage:

[object HTMLDivElement]
what is causing this? and how do I fix this?
Will need to see the code.

Somethings being written in JavaScript, by the looks of its grabbing a div, and instead of reporting the contents (or putting something in there or otherwise manipulating it) it's just taking the "type" of element and printing it.

Link to comment
https://linustechtips.com/topic/293402-object-htmldivelement/#findComment-3984201
Share on other sites

Link to post
Share on other sites

Will need to see the code.

Somethings being written in JavaScript, by the looks of its grabbing a div, and instead of reporting the contents (or putting something in there or otherwise manipulating it) it's just taking the "type" of element and printing it.

 

Which webpage? And which browser do you use?

sorry forgot the code

 

this is the html part :

<!doctype html><html>    <head>        <meta charset="utf-8">        <meta name="keywords" content="basisschool,sqool,cool,rekenen,tafels"> <!-- trefwoorden  -->        <meta name="author" content="Robin Bosman"> <!-- Auteur -->        <meta name="description" content="basisschool sqool tafel rekenen"> <!-- beschrijving pagina inhoud -->        <title>Tafels rekenen met basischool Sqool</title> <!-- Titel beschikbaar in het tab-blad -->        <link rel="stylesheet" href="css/styles.css"> <!-- link naar de stylesheet -->        <script type="text/javascript" src="js/toets.js"></script> <!-- hier wordt script opgeroepen -->    </head>    <body>        <section id="toets">            <header>                    <img src="img/banner.png" class="banner"></img> <!-- Dit is de banner -->                <nav> <!-- hier begint de navigatie -->                    <ul>                        <li><a href="index.html">Home</a></li>                        <li><a href="oefen.html">Oefenen</a></li>                        <li><a href="#top">Toetsen</a></li>                        <li><a href="informatie.html">Informatie</a></li>                        <li><a href="contact.html">Contact</a></li>                    </ul>                </nav> <!-- hier eindigt de  navigatie -->            </header>            <article class="content">                <header>                    <h1> Tafels Toetsen </h1> <!-- titel-->                </header>                <div id="output"></div>                                <script>                                    toets();                </script>                    </article>                <footer>                    <small>Basisschool Sqool © protected</small> <!-- footer -->                </footer>        </section>    </body></html>

and this the JS part:

function toets(){var antwoord = new Array();for (var x =0; x<30; x++)	{		var getal1 = Math.floor((Math.random()*10) + 1);		var getal2 = Math.floor((Math.random()*10) + 1)		antwoord[x] = getal1 * getal2;		output += ( getal1 + "x" + getal2 + " =" + "<input type = 'number'>"  );	}	document.getElementById("output").style.display = "block";	document.getElementById("output").innerHTML = output;	return false;}

Beneath this mask there is an idea, and ideas are bulletproof.

Link to comment
https://linustechtips.com/topic/293402-object-htmldivelement/#findComment-3985418
Share on other sites

Link to post
Share on other sites

In the toets function you are using a global "output" variable that already has a div element in it, you should declare a local variable to build the string by adding

var output = "";

to the top of the function.

thanks ^^

Beneath this mask there is an idea, and ideas are bulletproof.

Link to comment
https://linustechtips.com/topic/293402-object-htmldivelement/#findComment-3986407
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×