I need help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

I need help

If I want to include a div element in show function in javasript,how will I do it,is it like this,function show() document.write(document.getElementById("try");

4th Oct 2020, 9:34 AM
SANNI ABDUL-AMEEN OLUWADARASIMI
28 Answers
4th Oct 2020, 10:04 AM
Dipendra
Dipendra - avatar
+ 6
Yes
4th Oct 2020, 10:08 AM
Dipendra
Dipendra - avatar
+ 6
"Try" is not a tag name
4th Oct 2020, 10:12 AM
Dipendra
Dipendra - avatar
+ 6
Then use : Document.getElementById("try");
4th Oct 2020, 10:15 AM
Dipendra
Dipendra - avatar
+ 6
Can u share the code ?
4th Oct 2020, 10:40 AM
Dipendra
Dipendra - avatar
+ 6
Sure
4th Oct 2020, 11:13 AM
Dipendra
Dipendra - avatar
+ 5
Like this :: Document.getElementByTagName('div');
4th Oct 2020, 9:43 AM
Dipendra
Dipendra - avatar
+ 2
Thanks,so will it be like this document.write(document.getElementByTagname("div")
4th Oct 2020, 9:46 AM
SANNI ABDUL-AMEEN OLUWADARASIMI
+ 2
But it didn't work,it showed error, should I show you the whole code?
4th Oct 2020, 10:07 AM
SANNI ABDUL-AMEEN OLUWADARASIMI
+ 2
function show(){ document.write(document.getElementByTagname("try")) }
4th Oct 2020, 10:11 AM
SANNI ABDUL-AMEEN OLUWADARASIMI
+ 2
This is the JavaScript code
4th Oct 2020, 10:11 AM
SANNI ABDUL-AMEEN OLUWADARASIMI
+ 2
I created a div element in the html with the id name as try
4th Oct 2020, 10:13 AM
SANNI ABDUL-AMEEN OLUWADARASIMI
+ 2
It also didn't work,I don't even know what to do,maybe I will just abandon the code
4th Oct 2020, 10:31 AM
SANNI ABDUL-AMEEN OLUWADARASIMI
+ 2
The code is very simple,bt if I share it,can we work on it together
4th Oct 2020, 11:07 AM
SANNI ABDUL-AMEEN OLUWADARASIMI
+ 2
Let me screenshot it
4th Oct 2020, 11:13 AM
SANNI ABDUL-AMEEN OLUWADARASIMI
+ 1
Okay.in what way?
4th Oct 2020, 12:16 PM
Michael Victor
Michael Victor - avatar
0
I ve created a div element in html with the id as try
4th Oct 2020, 10:12 AM
SANNI ABDUL-AMEEN OLUWADARASIMI
0
Try this function show (){ var a = document.getElementById("try").value; document.write(a); }
5th Oct 2020, 1:02 AM
George S Mulbah II
George S Mulbah II - avatar
0
Thanks Yourmix Jnr
5th Oct 2020, 8:38 AM
SANNI ABDUL-AMEEN OLUWADARASIMI
0
Yourmix Jnr,the result of the code was undefined
5th Oct 2020, 8:44 AM
SANNI ABDUL-AMEEN OLUWADARASIMI