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: patch-diff.githubusercontent.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:8092c5b1-960b-48be-840d-39c06055f13a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED9C:3A671A:5F9229:7F4E34:697311D4 |
| html-safe-nonce | d50d7a163fad93f44111ef3d6c020ff3b7427b5a846ff4f663ade3894ab35bc4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDlDOjNBNjcxQTo1RjkyMjk6N0Y0RTM0OjY5NzMxMUQ0IiwidmlzaXRvcl9pZCI6IjEwNTQwNTY2MjA1NTcwMTM0NjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3f39f8bd2e9144b5d162d46c4a6165cab2e8e1b45de7b912842e0ddc780c1714 |
| 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 | 44ab3188c1dcfe3be0f9c3feca2e04e14fb79f120939ce2395e4f15ab96ec1d4 |
| 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 | a5e2b48bd1260476599758f5d253b5d24092ab84 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width