Question


One of JavaScripts powers is to be able to interact with the DOM directly. Youve seen this when using commands such as docu

Must be car Themed

My first JS-DOM

color:red;

text node!'); //creates 'This is a text node!'

color:blue; font-family: arial;

Clicker Counter: 0

Interface should look something like this, but does not have to be one for one like this picture

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note that the image you are referring to is not visible.But from the Notes you have given. I have inferred the following:

Save the file with extension.html and run it on browser.

Source Code:

<html>
<head>
   <title>My first JS-DOM</title>
   <style>
       #finished{
           color:blue;
           float:right;
       }
       #myUL{
           color:red;
       }
       h1{
           text-align: center;
       }
   </style>
</head>
<body>
   <h1>My First JS DOM TODO List</h1>
   <p id="finished">Finished Tasks : <span id="count">0</span></p>
   <button class = "add" onclick="addTask()">Add a task</button>
   <ul id="myUL">
      
   </ul>  
</body>
<script>
   function addTask(){
       var txt = window.prompt("What to add to the list?","");
       //creating the checkbox
       var x = document.createElement("INPUT");
       x.setAttribute("type", "checkbox");
       x.addEventListener( 'change', function() {
       if(this.checked) {
   var c = document.getElementById("count").innerHTML;
   var incr = parseInt(c)+1;
   document.getElementById("count").innerHTML=incr;
  
       } else {
   var c = document.getElementById("count").innerHTML;
   var incr = parseInt(c)-1;
   document.getElementById("count").innerHTML=incr;
   }
       });
       //creating the list
       var li = document.createElement("li");
        var t = document.createTextNode(txt);
        li.appendChild(x);
        li.appendChild(t);
        if (txt === '') {
       alert("You must write something!");
       } else {
       document.getElementById("myUL").appendChild(li);
       }
   }

</script><head> <title>My first JS-DOM</title> <style> #finished color:blue; float:right; } #myUL{ color:red; hi{ text-align: center;

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
Must be car Themed My first JS-DOM color:red; text node!'); //creates 'This is a text node!'...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • NEED HELP DIRECTIONS: Notice that there is one input area and two buttons There is a...

    NEED HELP DIRECTIONS: Notice that there is one input area and two buttons There is a place in the HTML reserved for < li > elements under the heading “Shopping List” Write a javascript program that will cause whatever the user inputs to be placed in a newly -created < li > tag and the tag placed inside the < ul > element whenever the user clicks the button Your program must not create any < li > tag is...

  • In this problem, you will create a selectable “To Do” List. To add a task to...

    In this problem, you will create a selectable “To Do” List. To add a task to this list, the user clicks the Add Task button and enters a description of the task. To delete a task from the list, the user selects the task and then clicks the Delete Task button. Open the HTML and JavaScript files provided as start-up files (index.html from within todo_list_Q.zip file). Then, review the HTML in this file. Note, within the div element, there is...

  • Javascript to edit a HTML file. Where to begin? <!doctype html> <html>    <head>      <meta charset="utf-8">      <title>TODO:...

    Javascript to edit a HTML file. Where to begin? <!doctype html> <html>    <head>      <meta charset="utf-8">      <title>TODO: Change The Title</title>    </head>    <body>      <h1></h1>      <p>First paragraph.</p>      <p class="intro">Second <span>paragraph</span>.</p>      <button id="start">Start</button>      <main> </main>      <!--       Test 6: DOM Programming       You MAY consult the notes for week 7, but you MAY NOT discuss this test or       your code with any other students.  All work must be your own.       Instructions:              1. Put all solution code in a file named solution.js.  When you upload your          solution to...

  • WEB230 - JavaScript 1 Assignment 6a Use Events and DOM manipulation to create a playable Tic...

    WEB230 - JavaScript 1 Assignment 6a Use Events and DOM manipulation to create a playable Tic Tac Toe game. Do the following using JavaScript. Do not modify the HTML file. When you see this symbol: save and refresh the browser (this should happen automatically if you are using Brackets with Live Preview), then check your code to make sure it is working before you proceed. 1. Create two variables called "playerX" and "playero". Set them to the DOM element with...

  • Hello! I am to create a .js file that allows the paragraph on the bottom of...

    Hello! I am to create a .js file that allows the paragraph on the bottom of the page to update with what the user enters. I need to modify the given HTML to recognize the javascript file that I am to make from scratch. The HTML file and other details are below: Use the given HTML to add functionality to an interactive form that generates an invitation to volunteers for an event. The file will have the following invitation message...

  • can you do this js and html question. ill give you the html and js and...

    can you do this js and html question. ill give you the html and js and css files just fix my error use if and else like what i did dont use switch just fix my erorr. <!DOCTYPE html> <!-- Webpage HTML document for Lab 4. Authors: Amirhossein Chinaei, Andriy Pavlovych For: EECS 1012, York University, Lassonde School of Engineering --> <html lang="En"> <head> <meta charset="UTF-8"> <!-- title for web page --> <title> EECS1012: Lab 4 - Computational Thinking </title>...

  • This is my code so far: <!DOCTYPE html> <html> <head> <title>JavaScript is fun</title> <meta charset="utf-8" />...

    This is my code so far: <!DOCTYPE html> <html> <head> <title>JavaScript is fun</title> <meta charset="utf-8" /> </head> <body> <script type ="text/javascript"> //declare a variable and store text in it var x = "JavaScript is fun"; //write the variable 5 times document.write(x + x + x + x + x); //store 5 as string in variable x x = "5"; //store 3 as string in variable y var y = "3"; //write the value x + y to the document document.write("<br>");...

  • i need help with this homework webpage and code too: The webpage must include: Global Structure...

    i need help with this homework webpage and code too: The webpage must include: Global Structure Tags Text Tags Images   Your first page must be named index.html Include a table within your site, challenge yourself to add a header in the table, and choose interesting border and/or cell formatting. Include a hyperlink within your site. Include an image in your site. Include a form in your site to demonstrate understanding of a variety of form components (the form does not...

  • Modify an application that lets users add tasks to a list so the tasks can also...

    Modify an application that lets users add tasks to a list so the tasks can also be deleted when they’re completed. 1. In the HTML file, enclose the text for each of the three existing list items in a <p> element. Then, Add buttons like the ones shown above preceding the <p> elements. No ids or names are required for these buttons, but they should be assigned to the class named “delete”. 2. In the JavaScript file, modify the event...

  • Design a program using Python and using from flask Import flask that generates a lottery number...

    Design a program using Python and using from flask Import flask that generates a lottery number but in a website.. The program should have an Integer array with 9 elements. Write a loop that steps through the array, randomly generating a number in the range of 0 through 42 for each element. (Use the random function) Then write another loop that displays the contents of the array. Each number should be displayed as a list, the numbers should be generated...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT