Question

abe 2 Use the provided HTML for the following questions. You only need to write the JavaScript code for the following questio
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi,

Please find below :

1.

HTML Code -- <input type="text" name="email" id="email">

JS Code -- var email = document.getElementById("email").value;

console.log(email);

2. HTML Code -- <input type="text" name="email" id="email">

JQUERY Code -- var str = $("#email").val();

console.log(email);

3. For preventing default action you need to use :

preventDefault() event method

Usage :

HTML Code -- <button id="submit">Submit</button>

JS Code -- Need to pass the button id on whose click we want to prevent the default action

document.getElementById("submit").addEventListener("click", function(event){
event.preventDefault()});

4.

HTML Code --

<input type="text" name="email" id="email">
<p id="emailError"></p>
<input type="submit" value="Submit" onclick="getVal()">

JS Code --

var email = document.getElementById("email").value;
if(!email){// To validate if anything is entered or not

//Search for the paragraph element and add the message string
   document.getElementById("emailError").innerHTML = "Please enter valid email";
}

5.

HTML Code -- <p id="emailError"></p>

JS Code -- var element = document.getElementById("emailError");

// This will add the class named error to the paragraph with id emailError
  element.classList.add("error");

6. You can switch the image of the page by getting the image id and then changing the source

document.getElementById('imgage').src='test.jpeg';

7.

So, if you want to add to the beginning of an array you can use unshift

var list = ["a", "b"];

list.unshift("c");

["c", "a", "b"] //result will look like

otherwise, if in between use splice

var list = ["a", "b"];

list.splice( 1, 0, "c"); // which position we want to place in this case inedx 1, remove 0 elements, then add "c" to that position

["a", "c", "b"]

Please like if you found helpful

Thank You

Add a comment
Know the answer?
Add Answer to:
abe 2 Use the provided HTML for the following questions. You only need to write the...
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
  • Write a calculator program using JavaScript in HTML in the same HTML file. (There will only...

    Write a calculator program using JavaScript in HTML in the same HTML file. (There will only be 1 HTML file containing everything that you use for this program.) *************JavaScript Functions should be written in the HTML <head> .............. </head> tag, **************** (Please be mindful of the formatting of the text of your program. Meaning that do not copy paste everything in a single line. Add clear comments for a better understanding of your program) as follows Assignment: create a form...

  • 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>");...

  • 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...

  • We use A porgram called :"Aptana" Any ideas please Help:( 1. Write an HTML file with...

    We use A porgram called :"Aptana" Any ideas please Help:( 1. Write an HTML file with one button. The value of the button should be your name. Name the file YourFirstName YourLastName.html 5 points. 2. Write a separate JavaScript file called YourFirstName YourLastname.js in the same folder. When the button is clicked, the program should prompt the user for a string, or *** to quit. It should read the string into a variable. 10 points 3. Assume the user enters...

  • NEED HELP with HTML with Javascript embedding for form validation project below. I have my code...

    NEED HELP with HTML with Javascript embedding for form validation project below. I have my code below but I'm stuck with validation. If anyone can fix it, I'd really appreciate. ****************************************************************************** CODE: <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <title>Nice</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> var textFromTextArea; function getWords(){ var text =...

  • Please help with this assignment section A. This question is from world wide web Info Sys Dev. Section A te HTML/JavaSc...

    Please help with this assignment section A. This question is from world wide web Info Sys Dev. Section A te HTML/JavaScript web page called sectiona.html, that has the fpllowing items: a. 2 text items labeled as "CAD Dollar" and "US Dollar", the first(CAD dollars) is enabled with id-"cad", while the later is disabled with id-us" b.1 button named as "convert". functionality: When the user clicks on the button, a JavaScript function named "convert" will be called to convert the value...

  • Task 3: Creating a Simple jQuery Application 1. Launch HTML-Kit. 2. Create a new HTML file...

    Task 3: Creating a Simple jQuery Application 1. Launch HTML-Kit. 2. Create a new HTML file and save it as nnLab8.htm. 3. Add the following HTML to the file: <!DOCTYPE HTML> <html> <head> <title>Hello World - jQuery Style</title> </head> <body> <div id="first"></div> <div id="second"></div> <a href="#" id="link">Click Me!</a><br /> <span id="greeting"></span> </body> </html> 4. Add the following<script> element to the<head> section. NOTE: Use the jQuery version number that matches the file name of the file you downloaded in Step 1....

  • 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...

  • I'm having trouble to link the .js file to the html so changes for the html...

    I'm having trouble to link the .js file to the html so changes for the html to be made in the .js file <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>:JavaScript, HTML and jQuery</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <!-- this is so I don't have to give you a separate CSS file --> <style>     .hidden {display: none;}     .menu { width: 100px;} </style> </head> <body> <div class="container"> <h1>Assignment 2: JavaScript, HTML and jQuery</h1> <p>To complete this...

  • Hello Ive been tryting to add the CDN of jquery to my html code and I...

    Hello Ive been tryting to add the CDN of jquery to my html code and I keep getting an error Need help with this : ​​ Navigate to www.code.jquery.com in your Chrome browser. On this page, you'll find different stable versions of jQuery. Select uncompressed for jQuery Core 3.3.1. Copy the <script> tag that is given to you. In store_hours.html, paste that tag directly above your body's closing tag. This is the jQuery CDN. After you paste this code into...

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