Need a little help at JS! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Need a little help at JS!

Hey guys, I am trying to make a program in JS; <button onclick="Jo ()"> A <button > <script> function Jo (){ document.write ("A")}</script> But after clicking the option A once it prints A and disappears, what I want is that the option A doesn't get disappear but works everytime and prints A, so what should I do to get this result? Thanks for answering.

8th Sep 2017, 5:24 PM
Isair Calhawk
Isair Calhawk - avatar
22 Answers
+ 7
I create a button tag which calls the Jo function if you click it Then I create a span tag which is going to contain all the A The Joo function first creates a new html p tag and saves it in a variable called a then it sets the innerHTML (content of the p tag) of the a variable Finally it gets the span html tag by using its id and add the p I just created in it
8th Sep 2017, 5:36 PM
Dapper Mink
Dapper Mink - avatar
+ 7
"Quentin" is French "カンタンジャヌエル" is my full name"QuentinJanuel" written in Japanese
9th Sep 2017, 5:19 PM
Dapper Mink
Dapper Mink - avatar
+ 6
<button onclick="Jo ()"> A </button> <span id="asdf"></span> <script> function Jo(){ var a = document.createElement("p"); a.innerHTML = "A"; document.getElementById("asdf").appendChild(a); } </script>
8th Sep 2017, 5:29 PM
Dapper Mink
Dapper Mink - avatar
+ 6
It's probably private, be sure you set it public Or else you can try mine which works fine https://code.sololearn.com/W98GkgaoKil1/?ref=app
9th Sep 2017, 5:09 PM
Dapper Mink
Dapper Mink - avatar
+ 6
Your error was "innerHtml" instead of "innerHTML" You're welcome, have a nice day :)
9th Sep 2017, 5:15 PM
Dapper Mink
Dapper Mink - avatar
+ 6
Why? Why not? I like using Japanese alphabets when I can
9th Sep 2017, 5:20 PM
Dapper Mink
Dapper Mink - avatar
+ 5
You're welcome, good luck and have fun coding!
8th Sep 2017, 5:38 PM
Dapper Mink
Dapper Mink - avatar
+ 5
I can't find any code on your profile :/
9th Sep 2017, 5:06 PM
Dapper Mink
Dapper Mink - avatar
+ 5
Quentin
9th Sep 2017, 5:16 PM
Dapper Mink
Dapper Mink - avatar
+ 5
I'm from France so this name may sound weird
9th Sep 2017, 5:17 PM
Dapper Mink
Dapper Mink - avatar
0
Not trying to be rude but your answer could be a lot of help if you could also explain me the code(•_•)
8th Sep 2017, 5:32 PM
Isair Calhawk
Isair Calhawk - avatar
0
Understood, thanks for answering bro :).
8th Sep 2017, 5:38 PM
Isair Calhawk
Isair Calhawk - avatar
0
You too!
8th Sep 2017, 5:39 PM
Isair Calhawk
Isair Calhawk - avatar
0
Um japanese guy(not trying to be rude), your code didn't work:( You can check it on my profile<codes<failure.
9th Sep 2017, 3:48 PM
Isair Calhawk
Isair Calhawk - avatar
0
huh? but I have saved it
9th Sep 2017, 5:07 PM
Isair Calhawk
Isair Calhawk - avatar
0
anyway, its not working :(
9th Sep 2017, 5:08 PM
Isair Calhawk
Isair Calhawk - avatar
0
oh its private, wait a sec I am gonna make it public
9th Sep 2017, 5:09 PM
Isair Calhawk
Isair Calhawk - avatar
0
done
9th Sep 2017, 5:10 PM
Isair Calhawk
Isair Calhawk - avatar
0
I got it and made it right. Thanks for your time :)
9th Sep 2017, 5:13 PM
Isair Calhawk
Isair Calhawk - avatar
0
Anyway, whats your name?
9th Sep 2017, 5:15 PM
Isair Calhawk
Isair Calhawk - avatar