+ 1

See and please tell where am i wrong?

<!DOCTYPE html> <html> <head> <title>Page Title</title> </head><div id="demo "style="width:200px"> some text </div> <script> var x=document.getElementById("demo"); x.style.width="500px"; </script> </html>

11th Oct 2020, 3:07 PM
RD:programmer
RD:programmer - avatar
3 Answers
+ 5
Try this one <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <div id="demo"width="200px"> some text </div> <script> var x=document.getElementById("demo"); x.style.width="500px"; </script> </html>
11th Oct 2020, 3:12 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 5
Rinku Das The reason the code failed was because you had an extra space character after demo in your div id. Id="demo " You are also missing the <body></body> tag although that won't cause it not to work.
11th Oct 2020, 8:39 PM
Paul K Sadler
Paul K Sadler - avatar
0
Ok
11th Oct 2020, 3:14 PM
RD:programmer
RD:programmer - avatar