0

Why "addEventListener" and jQuery do not work in CODE PLAYGROUND?

I want that than I push "Enter button" in corresponding field corresponding "button" is clicking. First I tried to solve my problem by jQuery, but it does not work (it seems library don't connected). So I dicided to write my code on clear JavaScript, but have new problem "addEventListener" don't work. By the way code is working 100% in my browser, but in CODE PLAYGROUND it does not work. Here is the code: https://code.sololearn.com/WP1pKRRtfN2X/#html . Please help.

19th Feb 2017, 5:14 PM
Yurii Zadorozhnyi
Yurii Zadorozhnyi - avatar
2 odpowiedzi
+ 3
Just wrap all your code from JS tab in a anonymized ( or not ) function assigned to the window.onload event: window.onload = function() { /* your code, at least initialization and start: if you want to deal with Dom, you need to wait for complete page loading */ }; The final semi-coma is requiring, as end an assignement. Anyway, be careful of syntax of parameter to pass to the method getElementById; contrarly to the querySelector() method and to JQuery selector syntax, you must not put the '#' at start of the id... so, lines in your script as: var enterNumbers = document.getElementById("#number"); ... needs to be corrected ( or replaced with original JQuery call, as I suspect this was rest of your attempt to adapt it without JQuery?
19th Feb 2017, 10:16 PM
visph
visph - avatar
0
Thank you. It helped. Also I found another my mistake. Now all working.
20th Feb 2017, 10:46 AM
Yurii Zadorozhnyi
Yurii Zadorozhnyi - avatar