Closed
Bug 1483890
Opened 6 years ago
Closed 6 years ago
Error in example code
Categories
(Developer Documentation Graveyard :: Learning Area, enhancement, P1)
Tracking
(Not tracked)
RESOLVED
INVALID
People
(Reporter: d.carballo, Assigned: cmills)
Details
What feature should be changed? Please provide the URL of the feature if possible. ================================================================================== https://developer.mozilla.org/es/docs/Learn/Getting_started_with_the_web/JavaScript_basics I was following the tutorial and I found that the line var myButton = document.querySelector('button'); throws a null exception in console, and ofc the button is not shown. It's also present in your github example code, and apparently is a common issue. What problems would this solve? =============================== Probably quite a lot. Who would use this? =================== Everyone. What would users see? ===================== Everyone interested in starting with JS. What would users do? What would happen as a result? =================================================== The'll copy the code, see it doesn't work, search about it, find it's not an isolated issue and it's exampled on MDN's page. Result? "Yay, I love javascript and mozilla ¬¬" Is there anything else we should know? ====================================== Translators maybe
Comment 1•6 years ago
|
||
The same code is on the English page, the translation appears up to date: https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics#Adding_a_personalized_welcome_message If an element is not found, document.querySelector returns null. Step 1 of that section is "Add a button just before the script element". It seems like the needed change is in index.html.
Component: Wiki pages → Learning Area
Product: developer.mozilla.org → Developer Documentation
Updated•6 years ago
|
Priority: -- → P1
Whiteboard: [specification][type:change]
Assignee | ||
Updated•6 years ago
|
Assignee: nobody → me
Assignee | ||
Updated•6 years ago
|
Assignee: me → cmills
Assignee | ||
Comment 2•6 years ago
|
||
Hi there, I have worked through the tutorial again to test it, and it seems to work fine for me. The line var myButton = document.querySelector('button'); Would throw a null exception in the console if the button it is supposed to be selecting is not available in HTML. Did you follow the first step in this section: https://developer.mozilla.org/es/docs/Learn/Getting_started_with_the_web/JavaScript_basics#A%C3%B1adiendo_un_mensaje_de_bienvenida_personalizado That tells you to add a button element to the HTML file? These parts aren't available in the GitHub code referenced from that because you are supposed to add them as part of the tutorial. The finished version has all the features needed: https://github.com/mdn/beginner-html-site-scripted Does this help, or is there still a problem? Please let me know if I've misunderstood the problem ;-)
Flags: needinfo?(d.carballo)
Reporter | ||
Comment 3•6 years ago
|
||
Hi, No you didn't misunderstood, that was me, sorry! As you checked and said (I've also checked both codes) everything works fine. Thank you very much.
Flags: needinfo?(d.carballo)
Reporter | ||
Updated•6 years ago
|
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → INVALID
Assignee | ||
Comment 4•6 years ago
|
||
(In reply to d.carballo from comment #3) > Hi, > > No you didn't misunderstood, that was me, sorry! As you checked and said > (I've also checked both codes) everything works fine. Thank you very much. No worries — glad you got it sorted!
You need to log in
before you can comment on or make changes to this bug.
Description
•