Code Monkey home page Code Monkey logo

dom-manipulation-2's Introduction

Lesson 1.7 : DOM Manipulation, Part 2 & Project Work Time

⌨️ String Interpolation:

  • Embedding values within a string is done using string interpolation.

  • This is achieved using template literals.

    let name = 'John';
    let greeting = `Hello, ${name}!`;
    console.log(greeting); // Outputs: Hello, John!
    • Template literals are enclosed by backticks (``).
    • Variables or expressions are placed inside ${...}.
    let a = 10;
    let b = 20;
    let result = `Sum of a and b is ${a + b}.`;
    console.log(result); // Outputs: The sum of a and b is 30.

📦 Storing Input Values:

  • Input fields allow websites to gather data from users.

    <input class="user-input" placeholder="Email">
    <button>Log in</button>
  • With JavaScript, you can extract the value of the input using the .value method.

    let button = document.querySelector("button");
    button.addEventListener("click", function() {
      let userInput = document.querySelector("input").value;
      console.log(userInput);
    });

✨ DOM & Styling:

  • Manipulate page styling using JavaScript and the .style property.

    let header = document.querySelector("h1");
    header.style.backgroundColor = "black";
    header.style.color = "lightGreen";
  • Be aware of camelCase for hyphenated properties in JS:

    • background-color becomes backgroundColor.
    • font-size becomes fontSize.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.