[JavaScript] - Understanding JavaScript Events and Form | SheCodes

[JavaScript] - Understanding JavaScript Events and Form Input

Learn how to use event.preventDefault() and querySelector() to access and manipulate elements of the DOM in JavaScript.

πŸ‘©β€πŸ’» Code to be explained

function search(event) {
  event.preventDefault();
  let input = document.querySelector("#city-input");
  console.log(search.value);

  let h5 = document.querySelector("h5");
  if (input.value) {
    h5.innerHTML = `${input.value}...`;
  } else {
    h5.innerHTML = null;
    alert(`${input.value}...`);
  }
}
let form = document.querySelector("#search-form");
form.addEventListener("submit", search);

More coding questions about JavaScript

πŸ‘©β€πŸ’» Technical question

what is template literals?

πŸ‘©β€πŸ’» Technical question

what is the difference between == and ===? in javascript

πŸ‘©β€πŸ’» Technical question

what is "Identifier has already been declared" ?

πŸ‘©β€πŸ’» Technical question

When the button is clicked, replace button label by β€˜18 degrees’

πŸ‘©β€πŸ’» Technical question

how To display a phone number card when pressing an icon

πŸ‘©β€πŸ’» Technical question

what is cache expire date 10368000 ?

πŸ‘©β€πŸ’» Technical question

JavaScript functions

πŸ‘©β€πŸ’» Technical question

how to declare a function in javascript

πŸ‘©β€πŸ’» Technical question

what is the main use of filter method in js

πŸ‘©β€πŸ’» Technical question

How do I use backtick in javascript

πŸ‘©β€πŸ’» Technical question

what is hasOwnProperty in js

πŸ‘©β€πŸ’» Technical question

What is await in js

πŸ‘©β€πŸ’» Technical question

Asked 1 month ago in JavaScript by Anastasiia

what is .toLowerCase()

πŸ‘©β€πŸ’» Technical question

what does .reduce() do?

πŸ‘©β€πŸ’» Technical question

explain toFixed method in javascript

πŸ‘©β€πŸ’» Technical question

how to acces to an object property inside an object

πŸ‘©β€πŸ’» Technical question

What is the infinity global property in Javascript and when is it used?

πŸ‘©β€πŸ’» HTML, CSS and JavaScript Code instructions

// Question: // Create a function that takes a string as a parameter // and alternates the casing of each individual letter // within the string. // Eg. Hello World! => hELLO wORLD!

πŸ‘©β€πŸ’» Technical question

what is a javascript function

πŸ‘©β€πŸ’» Technical question

what is forEach in javascript?

πŸ‘©β€πŸ’» Technical question

what is axios?

πŸ‘©β€πŸ’» Technical question

What is a comment in JavaScript?

πŸ‘©β€πŸ’» Technical question

how can I link my javascript file to a separate HTML file?

πŸ‘©β€πŸ’» Technical question

How to append the header to a html table in javascript?

πŸ‘©β€πŸ’» Technical question

how to get matching data from a prompt on an existing object

πŸ‘©β€πŸ’» Technical question

what are arguments in a function? Like what's a function that takes 2 arguments, name and email, look like?

πŸ‘©β€πŸ’» Technical question

can you nest objects javascript

πŸ‘©β€πŸ’» Technical question

What is the difference between setTimeout and setInterval?

πŸ‘©β€πŸ’» Technical question

Can you use forEach with an array of objects?

πŸ‘©β€πŸ’» Technical question

what are data types

πŸ‘©β€πŸ’» Technical question

how to make an svg image using javascript

πŸ‘©β€πŸ’» Technical question

How to iterate through numbers and return a string message if the sum is negative

πŸ‘©β€πŸ’» Technical question

Can you iterate through numbers decreasing?

πŸ‘©β€πŸ’» Technical question

how to sum all numbers in a range

πŸ‘©β€πŸ’» Technical question

how to use setTimeout

πŸ‘©β€πŸ’» Technical question

what is trim in javascript

πŸ‘©β€πŸ’» Technical question

how can we create element from javascript?

πŸ‘©β€πŸ’» Technical question

What are functions in JavaScript

πŸ‘©β€πŸ’» Technical question

can you explain what a promise is in javascript

πŸ‘©β€πŸ’» Technical question

teach me how to use array.reduce method in javascript

πŸ‘©β€πŸ’» Technical question

When do I use let and const

πŸ‘©β€πŸ’» Technical question

how do you use return in javascript

πŸ‘©β€πŸ’» Technical question

Which method is used to check if a specific element exists in a Set?

πŸ‘©β€πŸ’» Technical question

What does 'this' mean in JavaScript?

πŸ‘©β€πŸ’» Technical question

what is prompt in js

πŸ‘©β€πŸ’» Technical question

how to use .includes

πŸ‘©β€πŸ’» Technical question

differences of var, let, const in javascript

πŸ‘©β€πŸ’» Technical question

what iS NODE.JS

πŸ‘©β€πŸ’» Technical question

what is Math in js