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.
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
+ 7
"Quentin" is French
"カンタンジャヌエル" is my full name"QuentinJanuel" written in Japanese
+ 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>
+ 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
+ 6
Your error was "innerHtml" instead of "innerHTML"
You're welcome, have a nice day :)
+ 6
Why?
Why not? I like using Japanese alphabets when I can
+ 5
You're welcome, good luck and have fun coding!
+ 5
I can't find any code on your profile :/
+ 5
Quentin
+ 5
I'm from France so this name may sound weird
0
Not trying to be rude but your answer could be a lot of help if you could also explain me the code(•_•)
0
Understood, thanks for answering bro :).
0
You too!
0
Um japanese guy(not trying to be rude), your code didn't work:( You can check it on my profile<codes<failure.
0
huh? but I have saved it
0
anyway, its not working :(
0
oh its private, wait a sec I am gonna make it public
0
done
0
I got it and made it right. Thanks for your time :)
0
Anyway, whats your name?