Question

In: Computer Science

This should be done in JavaScript. The HTML file should only contain an empty main tag....

This should be done in JavaScript. The HTML file should only contain an empty main tag. All other HTML on the page should be created with JavaScript. The JavaScript file should be a separate file.  

  • Make an empty HTML file, put an empty main tag inside the body.
  • In your JavaScript, use querySelector to get a reference to the main tag and save it in a variable named main.
  • Look up three good jokes and store them as separate variables in your JavaScript.
  • Define an HTML template with a template string. Make a heading for your template that says "My Jokes" and make a list of your three jokes, inserting the variables as items in the list.
  • Put the template inside the main tag.
  • Make a paragraph tag with the document.createElement method and save it to a variable.
  • Add the text "That's all folks!" as text content to the newly created paragraph tag.
  • Append the paragraph tag to the body tag of your HTML page.

Solutions

Expert Solution

temp.htm

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

</head>

<body>

    <main></main>

    <script src="./temp.js"></script>

</body>

</html>

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

temp.js

const main = document.querySelector('main');

//jokes

const joke1 = `What do you call a crying sister? A crisis`;

const joke2 = `I have a joke on black hole but it sucks`;

const joke3 = `What do we call a bee born in United States? A USB`;

//template html string

const template = `<h3>My Jokes</h3>

<ul>

<li>${joke1}</li>

<li>${joke2}</li>

<li>${joke3}</li>

</ul>`;

//set main to template

main.innerHTML = template;

//create paragraph and text node

const para = document.createElement('p');

const text = document.createTextNode("That's all folks!");

para.appendChild(text);

document.body.appendChild(para);


Related Solutions

This needs to be written in JavaScript with two files. One HTML file and a JavaScript...
This needs to be written in JavaScript with two files. One HTML file and a JavaScript file. Make an empty HTML file, put three buttons inside the body and an empty main tag below the buttons. The text of the buttons should be "Foo", "Bar", and "FooBar" respectively. Don't put the " in the buttons that's just for clarification in these instructions. Add unique IDs to each button In your JavaScript, get 3 separate references to the buttons using the...
use VISUAL STUDIO CODE to write this javascript program Exercise 1 (a) Create a HTML file...
use VISUAL STUDIO CODE to write this javascript program Exercise 1 (a) Create a HTML file that uses createElement and appendChild to dynamically insert three paragraphs when a button is clicked. (b) Create a HTML file that includes JavaScript that is similar to: let recs = [“my item …1”,”my item…2”, …] i.e. an array that contains several CSV item records. When the user clicks a button, each array element will be rendered as a list element. Use a HTML list....
Create an ASP.NET Core MVC solution, edit the main view to contain an HTML form that...
Create an ASP.NET Core MVC solution, edit the main view to contain an HTML form that asks for first name, last name, and email address. The form should also have a submit button, though the submit button doesn't have to do anything yet. looking for an HTML mockup inside an ASP.NET Core MVC Solution.
HTML document containing a form. The title bar should display “Voting Form”. The form should contain...
HTML document containing a form. The title bar should display “Voting Form”. The form should contain the following: Text boxes to accept the person’s name and e-mail address At least five radio buttons the user can use to vote for a candidate for some office. (You make up some names) Text box for write-in alternative Checkboxes with name and value attributes for these options: oThis is the first time I have voted online. o I have periodically voted online. o...
Write a log-in log-out session using PHP, CSS, and HTML only. NO MYSQL and JavaScript allowed....
Write a log-in log-out session using PHP, CSS, and HTML only. NO MYSQL and JavaScript allowed. 1. Need an HTML form and a login form; separate file. 2. need a CSS file to make it look good 3. Must store visitors' info in a .txt file and validate from there if the user exists before granting access to the dashboard. If the user does not exist, render the form to signup. If the user exists take them to their dashboard....
HTML Create a page of texts that uses inline elements. The page should contain a citation,...
HTML Create a page of texts that uses inline elements. The page should contain a citation, a term definition, a subscript, a superscript and some highlighted texts.
Write a C++ program to create a text file. Your file should contain the following text:...
Write a C++ program to create a text file. Your file should contain the following text: Batch files are text files created by programmer. The file is written in notepad. Creating a text file and writing to it by using fstream: to write to a file, you need to open thew file as write mode. To do so, include a header filr to your program. Create an object of type fsrteam. Open the file as write mode. Reading from a...
Assignment Description: In this assignment, a script file should be created to contain a set a...
Assignment Description: In this assignment, a script file should be created to contain a set a SQL statements for the Pretty Prints Company to better manage their business. Use the database created for Pretty Prints in Assignment 2. Include the SQL statements to satisfy the following queries. The following queries should be included in the script: Create a view named Under_100. It consists of the item_id, title, artist, unit_price and order_qty for every print with a unit_price under 100 dollars....
C++ If you tried to compile a source file that doesn't contain a main() function, would...
C++ If you tried to compile a source file that doesn't contain a main() function, would this error be detected by the preprocessor, the compiler, or the linker? Briefly justify your answer. Hint: think about how the files that don't have main() get processed in a project with multiple files. Alternatively, try it out and look at the error message you get.
This should be done in as an Excel file. Using the simple time value of money...
This should be done in as an Excel file. Using the simple time value of money concepts from Corporate Finance course: Calculate the price of an annual coupon‐bond with a par value of $1,000, time to maturity of 10 years, coupon rate of 10% and yield to maturity of 12% (bond DC). yield to maturity of 8% (bond PC). Do the sensitivity analysis on the price of these two bonds (bond DC & bond PC) by changing the following (one...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT