linux1880 Posted May 28, 2011 Share Posted May 28, 2011 why i am getting b is null error ? <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title>createelement</title> <script type="text/javascript" charset="utf-8"> var b = document.getElementById('clickme'), count = 0; b.onclick = function () { count += 1; b.innerHTML = "Click me: " + count; }; </script> </head> <body> <button id="clickme">click me </button> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/237702-javascript-null-error/ Share on other sites More sharing options...
mikesta707 Posted May 28, 2011 Share Posted May 28, 2011 what line are you getting this error on? Quote Link to comment https://forums.phpfreaks.com/topic/237702-javascript-null-error/#findComment-1221563 Share on other sites More sharing options...
seanlim Posted May 30, 2011 Share Posted May 30, 2011 semicolon instead of comma to end the line... var b = document.getElementById('clickme'), Quote Link to comment https://forums.phpfreaks.com/topic/237702-javascript-null-error/#findComment-1222128 Share on other sites More sharing options...
fugix Posted May 30, 2011 Share Posted May 30, 2011 semicolon instead of comma to end the line... var b = document.getElementById('clickme'), yep, you are never actually ending your var definition Quote Link to comment https://forums.phpfreaks.com/topic/237702-javascript-null-error/#findComment-1222129 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.