could you please show me what I am doing wrong in the Javascript code below.
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
#mytext
{
color: white;
text-align: center;
}
</style>
<script>
var words = "The cat sat on the mat";
document.writeln("id='mytext"+ words ');
</script>
</head>
<body>
</body>
</html>
we can't call the id in document.writeln() but we can call the document.getElementById() by using this DOM we can call the id of tag and we can perform the certain operaton:
code using docuemnt.writeln()
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
div
{
color: green;
text-align: center;
}
</style>
<script>
var words = "The cat sat on the mat";
document.writeln('<div>'+words+ '</div>');
</script>
</head>
<body>
</body>
</html>
#output:

#if you have any doubts comment below...
could you please show me what I am doing wrong in the Javascript code below. <html>...
The code below modifies the CSS style on button click. Give the output of the code and modify the code such that background color of title should also be modified . <!DOCTYPE html> <html lang="en"> <head> <title>JavaScript and HTML</title> <meta charset="utf-8"/> <style> h1 { color:blue; background-color:lightGreen; border:12px solid green; padding: 5px; border-radius: 15px; text-align: center; } p, h1 { } } </style> <script> function changeTitleCSSStyle() { var title = document.querySelector("#mainTitle"); title.style.color = 'black'; title.style.border = "5px dashed red"; } </script>...
use the sample html file below with a submit button to modify the style of the paragraph text through JavaScript code. By clicking on the button, the font, the font size, and the color of the paragraph text will be changed. <!DOCTYPE html> · <html> · <head> · <meta charset=utf-8 /> · <title>Change Paragraph Text</title> · </head> · <body> · <p id ='text'>I’m going to change this text, I hope.</p> · <div> · <button id="jschange" · onclick="js_style()">Style</button> · </div> · </body> · </html>
This is an HTML and javascript code that I tried to replicate form this video but it wouldn't work for me for some reason can you help me fix this issue. thanks, https://youtu.be/F7C30e7gR2Y <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>cicle Animation in js</title> <style> body { height: auto; margin: 0; } #ocean { position: absolute; width: 100%; min-height: 100%; background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, 50, 150)), color-stop(0.50, rgb(0, 150, 255)); } .wave { background: blue ; display:...
This question relates to Javascript. Could you please show me why my code is not working? I want to create 2 text boxes and have the user enter something into both of them. If the text entered into both boxes is identical the a green message is made visible. If the boxes are different a red message is made visable. Please keep it simple because I am new to javascript. <html> <head> <title></title> <script>...
This question relates to Javascript. Could you please show me why my code is not working? I want to create 2 text boxes and have the user enter something into both of them. If the text entered into both boxes is identical the a green message is made visible. If the boxes are different a red message is made visable. Please keep it simple because I am new to javascript. <html> <head> <title></title> <script>...
In this Javascript code, why are 2 for loops needed? could you please explain this to me. This is the outcome * ** *** **** ***** ****** ******* ******** ********* the code is <html> <head> <title></title> <script> showStars(10); function showStars(rows){ for(var i = 0; i < rows; i++){ var pattern = ""; for(var j...
Please help me with the following requirements for JavaScript. Write a function to take a temperature value in Celsius as an argument and return the equivalent temperature in Fahrenheit, basing it on the code from Hour 2. //Original Code <!DOCTYPE html> <html> <head> <title>Fahrenheit From Celsius</title> </head> <body> <script> var cTemp = 100; // temperature in Celsius var hTemp = ((cTemp * 9) /5 ) + 32; document.write("Temperature in Celsius: " + cTemp + " degrees<br/>"); document.write("Temperature in Fahrenheit: "...
in the following java script code follow the instructions provided <!DOCTYPE html> <html> <head> <!-- JavaScript 6th Edition Chapter 5 Hands-on Project 5-2 Author: Date: Filename: index.htm --> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Hands-on Project 5-2</title> <link rel="stylesheet" href="styles.css" /> <script src="modernizr.custom.05819.js"></script> </head> <body> <header> <h1> Hands-on Project 5-2 </h1> </header> <article> <h2>Change of address form</h2> <form> <fieldset id="contactinfo"> <label for="addrinput"> Street Address </label> <input type="text" id="addrinput" name="Address" /> <label for="cityinput"> City </label> <input type="text" id="cityinput" name="City"...
This question relates to JavaScript. Could you please show me how to get my code below working. Please keep it simple. The code has a green square image. When it is clicked the function generates a random number from 1-3. If the number generated is '1' then the green square is replaced by a picture of a tree. Please keep it as simple as possible because I am new to coding. Thanks. <html> <head> <title></title> <script>...
I am trying to create a slide show using JavaScript. This is what I have so far: HTML: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Slide Show</title> <link rel="stylesheet" href="main.css"> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <script src="slide_show.js"></script> </head> <body> <section> <h1>Fishing Slide Show</h1> <ul id="image_list"> <li><a href="images/casting1.jpg" title="Casting on the Upper Kings"></a></li> <li><a href="images/casting2.jpg" title="Casting on the Lower Kings"></a></li> <li><a href="images/catchrelease.jpg" title="Catch and Release on the Big Horn"></a></li> <li><a href="images/fish.jpg" title="Catching on the South Fork"></a></li> <li><a href="images/lures.jpg" title="The Lures for Catching"></a></li> </ul>...