{"id":23741,"date":"2020-10-05T21:57:49","date_gmt":"2020-10-06T04:57:49","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=23741"},"modified":"2023-12-01T04:01:25","modified_gmt":"2023-12-01T12:01:25","slug":"javascript-cannot-set-property-innerhtml-of-null","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/","title":{"rendered":"JavaScript Uncaught TypeError: cannot set property \u2018innerHTML\u2019 of null Solution"},"content":{"rendered":"\n<p>The <a href=\"https:\/\/careerkarma.com\/blog\/javascript-innertext-innerhtml\/\">innerHTML property<\/a> lets you set the contents of an element using JavaScript.<br><\/p>\n\n\n\n<p>If you specify an invalid element with which to use the innerHTML method, or if you place your script before the element appears on the page, you\u2019ll encounter the \u201cUncaught TypeError: cannot set property \u2018innerHTML\u2019 of null\u201d error.<br><\/p>\n\n\n\n<p>In this guide, we discuss what this error means and why you may encounter it. We\u2019ll walk through an example of this error so you can learn how to resolve it in your JavaScript code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Uncaught TypeError: cannot set property \u2018innerHTML\u2019 of null<\/h2>\n\n\n\n<p>The innerHTML property is associated with any web element that you are working with in JavaScript. You may have selected a web element from the page using a \u201cgetter\u201d like <a href=\"https:\/\/careerkarma.com\/blog\/javascript-getelementbyidv\/\">getElementById()<\/a>, or you may have created an element in JavaScript that you want to modify.<br><\/p>\n\n\n\n<p>The \u201ccannot set property \u2018innerHTML\u2019 of null\u201d error is a type error. This means we are trying to apply a property or a function to a value that does not support a property or function.<br><\/p>\n\n\n\n<p>In this case, we\u2019re trying to set the value of innerHTML on an element that is equal to null. Null values do not have an innerHTML property.<br><\/p>\n\n\n\n<p>There are two common causes of this error:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Placing a script before an element appears on the web page<\/li><li>Referencing the wrong element ID.<\/li><\/ul>\n\n\n\n<p>We\u2019re going to walk through the first cause, which is arguably the most common mistake made by beginners.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">An Example Scenario<\/h2>\n\n\n\n<p>We\u2019re going to write a simple website that displays the time. To start, define a basic HTML page. This HTML page will be the canvas on which we display the time:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;en&quot;&gt;\n\t&lt;head&gt;\n\t\t&lt;title&gt;Time&lt;\/title&gt;\n\t&lt;\/head&gt;\n\t&lt;body&gt;\n\t\t&lt;p&gt;The time is &lt;span id=&quot;show_time&quot;&gt;&lt;\/span&gt;.&lt;\/p&gt;\n\t&lt;\/body&gt;\n&lt;\/html&gt;<\/pre><\/div>\n\n\n\n<p>This HTML page contains a <code>&lt;head&gt;<\/code> and a <code>&lt;body&gt;<\/code> tag. The <code>&lt;head&gt;<\/code> tag contains a <code>&lt;title&gt;<\/code> tag which defines the title for the web page. The <code>&lt;body&gt;<\/code> tag contains a paragraph.<br><\/p>\n\n\n\n<p>Within the paragraph, we have added a <a href=\"https:\/\/careerkarma.com\/blog\/html-span\/\">&lt;span&gt; tag<\/a>. We\u2019re going to replace the contents of this tag with the current time in our JavaScript code.<br><\/p>\n\n\n\n<p>Next, write a script to retrieve the time. We\u2019ll add this JS code inside the <code>&lt;head&gt;<\/code> tag:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>\u2026\n&lt;title&gt;Time&lt;\/title&gt;\n&lt;script&gt;\n\tvar show_time = document.getElementById(&quot;show_time&quot;);\n\tvar current_date = new Date();\n\n\tvar pretty_time = `${current_date.getHours()}:${current_date.getMinutes()}`\n\n\tshow_time.innerHTML = pretty_time;\n&lt;\/script&gt;\n\u2026<\/pre><\/div>\n\n\n\n<p>Our document now contains HTML and JavaScript. The <code>getElementById()<\/code> method retrieves our <code>show_time<\/code> span tag. We then retrieve the current date using the <a href=\"https:\/\/careerkarma.com\/blog\/javascript-date\/\">JavaScript Date module<\/a>.<br><\/p>\n\n\n\n<p>On the next line of code, we create a string which displays the current hour of the day and the minute of the hour. This string uses the following structure:<\/p>\n\n\n\n<p><code>HH:MM<\/code><\/p>\n\n\n\n<p>There is a colon that separates the hour and minute values. We create this string using a technique called <a href=\"https:\/\/careerkarma.com\/blog\/javascript-string-interpolation\/\">JavaScript string interpolation<\/a>. This lets us embed multiple values into the same string. Finally, we use the innerHTML method to display this time on our web page.<br><\/p>\n\n\n\n<p>Let\u2019s open up our web page in the web browser:<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/anZ4ckRYEF5OaualeffjXeLSKVdoZPV32w1Nl8cpU-YEy5nQeJ0KGFVR1DRUUwylZjjqemanwOj5z7NlgdEQ_qdcgAYzjdRMP9gFpr7tv4llZiOidmnmavbFUMa2ljCLqw\" alt=\"\"\/><\/figure>\n\n\n\n<p>Our web page fails to display the time. If we look at the JavaScript console, we can see an error:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Uncaught TypeError: show_time is null<\/pre><\/div>\n\n\n\n<p>This is another representation of the \u201ccannot set property \u2018innerhtml\u2019 of null\u201d. It tells us the element on which we are trying to set the value of innerHTML is null.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Solution<\/h2>\n\n\n\n<p>Because the value of <code>show_time<\/code> is null, we can infer that JavaScript was unable to successfully retrieve the element whose ID is <code>show_time<\/code>.<br><\/p>\n\n\n\n<p>In this case, the cause is that we have placed our <code>&lt;script&gt;<\/code> tag too early in our program. Our <code>&lt;script&gt;<\/code> tag appears in the header of our page. This is a problem because without using an <code>onload()<\/code> function, we can only select elements that come before our <code>&lt;script&gt;<\/code>.<br><\/p>\n\n\n\n<p>To solve this error, we need to move our <code>&lt;script&gt;<\/code> below our paragraph:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>...\n&lt;body&gt;\n\t\t&lt;p&gt;The time is &lt;span id=&quot;show_time&quot;&gt;&lt;\/span&gt;.&lt;\/p&gt;\n\t&lt;\/body&gt;\n&lt;script&gt;\n\tvar show_time = document.getElementById(&quot;show_time&quot;);\n\tvar current_date = new Date();\n\n\tvar pretty_time = `${current_date.getHours()}:${current_date.getMinutes()}`\n\n\tshow_time.innerHTML = pretty_time;\n&lt;\/script&gt;\n\u2026<\/pre><\/div>\n\n\n\n<p>We have moved our <code>&lt;script&gt;<\/code> tag below the <code>&lt;body&gt;<\/code> tag. Let\u2019s try to open our web page again:<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/wXdDOqcvpJPcVrh_90o-b25pwG2FPG8zxu97lBVNt_IcP6qWUWwhXk_pPOkEeNhT72Xa9ooa0LeoLvGrKH8JbHuVCYi3N6TKMlpuFTXRoBkgMv_GMRa58Lr85YOr82n8jw\" alt=\"\"\/><\/figure>\n\n\n\n<p>The web page successfully displays the time.<br><\/p>\n\n\n\n<p>If this does not solve the error for you, make sure that you correctly select the element that you want to work with in your code. For instance, consider this line of code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>var show_time = document.getElementById(&quot;show_times&quot;);<\/pre><\/div>\n\n\n\n<p>If we used this line of code to select our element, we would see the same error that we encountered before. This is because there is no element whose ID is \u201cshow_times\u201d.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The \u201cUncaught TypeError: cannot set property \u2018innerHTML\u2019 of null\u201d error is caused by trying to set an innerHTML value for an element whose value is equal to null.&nbsp;<br><\/p>\n\n\n\n<p>To solve this error, make sure your <code>&lt;script&gt;<\/code> tag comes after the element that you want to select in your script. If this does not solve the issue, check to make sure you are selecting a valid element in your program.<\/p>\n","protected":false},"excerpt":{"rendered":"The innerHTML property lets you set the contents of an element using JavaScript. If you specify an invalid element with which to use the innerHTML method, or if you place your script before the element appears on the page, you\u2019ll encounter the \u201cUncaught TypeError: cannot set property \u2018innerHTML\u2019 of null\u201d error. In this guide, we&hellip;","protected":false},"author":240,"featured_media":19656,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11933],"tags":[],"class_list":{"0":"post-23741","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-javascript"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"JavaScript","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":[]},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>JavaScript TypeError: cannot set property \u2018innerHTML\u2019 | Career Karma<\/title>\n<meta name=\"description\" content=\"On Career Karma, learn about the JavaScript Uncaught TypeError: cannot set property \u2018innerHTML\u2019 of null error, why the error is raised, and how to solve the error.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Uncaught TypeError: cannot set property \u2018innerHTML\u2019 of null Solution\" \/>\n<meta property=\"og:description\" content=\"On Career Karma, learn about the JavaScript Uncaught TypeError: cannot set property \u2018innerHTML\u2019 of null error, why the error is raised, and how to solve the error.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-10-06T04:57:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:01:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"667\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-cannot-set-property-innerhtml-of-null\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-cannot-set-property-innerhtml-of-null\\\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"JavaScript Uncaught TypeError: cannot set property \u2018innerHTML\u2019 of null Solution\",\"datePublished\":\"2020-10-06T04:57:49+00:00\",\"dateModified\":\"2023-12-01T12:01:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-cannot-set-property-innerhtml-of-null\\\/\"},\"wordCount\":764,\"commentCount\":1,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-cannot-set-property-innerhtml-of-null\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg\",\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-cannot-set-property-innerhtml-of-null\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-cannot-set-property-innerhtml-of-null\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-cannot-set-property-innerhtml-of-null\\\/\",\"name\":\"JavaScript TypeError: cannot set property \u2018innerHTML\u2019 | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-cannot-set-property-innerhtml-of-null\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-cannot-set-property-innerhtml-of-null\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg\",\"datePublished\":\"2020-10-06T04:57:49+00:00\",\"dateModified\":\"2023-12-01T12:01:25+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"On Career Karma, learn about the JavaScript Uncaught TypeError: cannot set property \u2018innerHTML\u2019 of null error, why the error is raised, and how to solve the error.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-cannot-set-property-innerhtml-of-null\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-cannot-set-property-innerhtml-of-null\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-cannot-set-property-innerhtml-of-null\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg\",\"width\":1000,\"height\":667},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-cannot-set-property-innerhtml-of-null\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"JavaScript Uncaught TypeError: cannot set property \u2018innerHTML\u2019 of null Solution\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/author\\\/jamesgallagher\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"JavaScript TypeError: cannot set property \u2018innerHTML\u2019 | Career Karma","description":"On Career Karma, learn about the JavaScript Uncaught TypeError: cannot set property \u2018innerHTML\u2019 of null error, why the error is raised, and how to solve the error.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Uncaught TypeError: cannot set property \u2018innerHTML\u2019 of null Solution","og_description":"On Career Karma, learn about the JavaScript Uncaught TypeError: cannot set property \u2018innerHTML\u2019 of null error, why the error is raised, and how to solve the error.","og_url":"https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-10-06T04:57:49+00:00","article_modified_time":"2023-12-01T12:01:25+00:00","og_image":[{"width":1000,"height":667,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"JavaScript Uncaught TypeError: cannot set property \u2018innerHTML\u2019 of null Solution","datePublished":"2020-10-06T04:57:49+00:00","dateModified":"2023-12-01T12:01:25+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/"},"wordCount":764,"commentCount":1,"image":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg","articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/","url":"https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/","name":"JavaScript TypeError: cannot set property \u2018innerHTML\u2019 | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg","datePublished":"2020-10-06T04:57:49+00:00","dateModified":"2023-12-01T12:01:25+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"On Career Karma, learn about the JavaScript Uncaught TypeError: cannot set property \u2018innerHTML\u2019 of null error, why the error is raised, and how to solve the error.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/tirza-van-dijk-I8OhOu-wLO4-unsplash.jpg","width":1000,"height":667},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/javascript-cannot-set-property-innerhtml-of-null\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/careerkarma.com\/blog\/javascript\/"},{"@type":"ListItem","position":3,"name":"JavaScript Uncaught TypeError: cannot set property \u2018innerHTML\u2019 of null Solution"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/23741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=23741"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/23741\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/19656"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=23741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=23741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=23741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}