Title: Why can't I set an attribute to an element through JS ? · Issue #12 · bethrobson/Head-First-JavaScript-Programming · GitHub
Open Graph Title: Why can't I set an attribute to an element through JS ? · Issue #12 · bethrobson/Head-First-JavaScript-Programming
X Title: Why can't I set an attribute to an element through JS ? · Issue #12 · bethrobson/Head-First-JavaScript-Programming
Description: function init() { var drink = document.getElementById("coffee"); drink.innerHTML = "I love tea."; drink.setAttribute("color", "red"); } window.onload = init; I love coffee. This is my code. I have selected the element with the id "coffee...
Open Graph Description: function init() { var drink = document.getElementById("coffee"); drink.innerHTML = "I love tea."; drink.setAttribute("color", "red"); } window.onload = init; I love coffee. This is my code. I have ...
X Description: function init() { var drink = document.getElementById("coffee"); drink.innerHTML = "I love tea."; drink.setAttribute("color", "red"); } window.onload = init;...
Opengraph URL: https://github.com/bethrobson/Head-First-JavaScript-Programming/issues/12
X: @github
Domain: www.github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Why can't I set an attribute to an element through JS ?","articleBody":"function init() {\n var drink = document.getElementById(\"coffee\"); \n drink.innerHTML = \"I love tea.\";\n drink.setAttribute(\"color\", \"red\");\n }\n\n```\nwindow.onload = init; \n```\n\n\u003cp id =\"coffee\"\u003e I love coffee. \u003c/p\u003e\n\n\nThis is my code. \nI have selected the element with the id \"coffee\" and assigned it to the variable \"drink\".\nI changed its content with the \"innerHTML\" property.\nAnd, now, I want to set a \"color\" attribute to the element .\nWhat's wrong with my code ? Why is the color not changing ??\n","author":{"url":"https://github.com/adityathebe","@type":"Person","name":"adityathebe"},"datePublished":"2015-07-23T17:31:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/12/Head-First-JavaScript-Programming/issues/12"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:93e9e38f-39d3-d9ed-ca71-1e4a2879c39c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A6B2:12DFF0:299B749:39B9064:6A632D2B |
| html-safe-nonce | 017dfb6a08fecda23e5570b17281a7bebbf9dd763e99a5c946cf14f1838c9b10 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNkIyOjEyREZGMDoyOTlCNzQ5OjM5QjkwNjQ6NkE2MzJEMkIiLCJ2aXNpdG9yX2lkIjoiNTEwMDUzODY3Mzg1Njk4MjMxNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d8f5d5c1ba48bc1d4fb6ec7ae61a5ee87e9c012238352514a07f410a0195cb37 |
| hovercard-subject-tag | issue:96863814 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/bethrobson/Head-First-JavaScript-Programming/12/issue_layout |
| twitter:image | https://opengraph.githubassets.com/42dd8596de744bb2bce6ac792c13feb5da1aec7d9f801719be30078f8519fdbd/bethrobson/Head-First-JavaScript-Programming/issues/12 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/42dd8596de744bb2bce6ac792c13feb5da1aec7d9f801719be30078f8519fdbd/bethrobson/Head-First-JavaScript-Programming/issues/12 |
| og:image:alt | function init() { var drink = document.getElementById("coffee"); drink.innerHTML = "I love tea."; drink.setAttribute("color", "red"); } window.onload = init; I love coffee. This is my code. I have ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | adityathebe |
| hostname | github.com |
| expected-hostname | github.com |
| None | 30c644d502bce6cd2e59f9000b4744f2b64819abea8e8f959b18e3ad793125aa |
| turbo-cache-control | no-preview |
| go-import | github.com/bethrobson/Head-First-JavaScript-Programming git https://github.com/bethrobson/Head-First-JavaScript-Programming.git |
| octolytics-dimension-user_id | 30760 |
| octolytics-dimension-user_login | bethrobson |
| octolytics-dimension-repository_id | 8868903 |
| octolytics-dimension-repository_nwo | bethrobson/Head-First-JavaScript-Programming |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 8868903 |
| octolytics-dimension-repository_network_root_nwo | bethrobson/Head-First-JavaScript-Programming |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 331492a48ebd91d66ef2de38e1901bb911c9fe9b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width