TGViewer
Web Development Web Development @webdevcoursefree ยท 79.6K subscribers
Post #3672 4.61K
โšก JavaScript Basics (Make Your Website Alive ๐Ÿง ๐Ÿ”ฅ)

๐Ÿ‘‰ HTML = Structure 
๐Ÿ‘‰ CSS = Design 
๐Ÿ‘‰ JavaScript = Brain (Logic + Interactivity)

๐Ÿง  What is JavaScript?

๐Ÿ‘‰ Programming language used to: 
โ€ข Add interactivity
โ€ข Handle user actions
โ€ข Update content dynamically

๐Ÿ’ก Example: 
โ€ข Button click
โ€ข Form validation
โ€ข Show/hide elements

๐Ÿ”‘ Variables (Store Data) 
let name = "Deepak"; 
let age = 25; 
๐Ÿ‘‰ Used to store values 

๐Ÿ” Conditions (Decision Making) 
if (age > 18) { 
  console.log("Adult"); 
} 

๐Ÿ”„ Loops (Repeat Work) 
for (let i = 1; i <= 5; i++) { 
  console.log(i); 
} 

๐Ÿ”ง Functions (Reusable Code) 
function greet() { 
  console.log("Hello World"); 
} 

greet(); 

๐ŸŒ DOM Manipulation (Most Important ๐Ÿ”ฅ)

๐Ÿ‘‰ DOM = Document Object Model 
๐Ÿ‘‰ Lets you control HTML using JS 

document.getElementById("title").innerText = "Hello JS ๐Ÿš€"; 

๐Ÿ’ก You can: 
โ€ข Change text
โ€ข Change styles
โ€ข Add/remove elements

๐Ÿ–ฑ๏ธ Events (User Actions)

document.getElementById("btn").addEventListener("click", function() { 
  alert("Button clicked!"); 
}); 

๐Ÿ‘‰ Common events: 
โ€ข click
โ€ข input
โ€ข submit

๐ŸŽฏ Mini Project

๐Ÿ‘‰ Create a button: 
โ€ข On click โ†’ change text
โ€ข On click โ†’ change background color

โšก Mini Project โ€“ Complete Solution (Button Interaction) ๐Ÿ”ฅ

๐Ÿ‘‰ Button click โ†’ change text + change background color 

๐Ÿ’ป Full Code 
<!DOCTYPE html>
<html>
<head>
  <title>JS Mini Project</title>
  <style>
    body {
      text-align: center;
      margin-top: 50px;
    }

    button {
      padding: 10px 20px;
      font-size: 18px;
      cursor: pointer;
    }
  </style>
</head>

<body>

  <h1 id="title">Hello World ๐Ÿ‘‹</h1>
  <button id="btn">Click Me ๐Ÿš€</button>

  <script>
    document.getElementById("btn").addEventListener("click", function() {
     
      // Change text
      document.getElementById("title").innerText = "You clicked the button! ๐ŸŽ‰";
     
      // Change background color
      document.body.style.backgroundColor = "lightblue";
     
    });
  </script>

</body>
</html>


๐Ÿง  How It Works (Simple Breakdown)

1๏ธโƒฃ Select Button 
document.getElementById("btn") 

2๏ธโƒฃ Add Click Event 
.addEventListener("click", function() {}) 

3๏ธโƒฃ Change Text 
document.getElementById("title").innerText = "New Text" 

4๏ธโƒฃ Change Background 
document.body.style.backgroundColor = "lightblue" 

๐ŸŽฏ Output

๐Ÿ‘‰ Click button โ†’ 
โœ” Text changes 
โœ” Background color changes 

๐Ÿ”ฅ Bonus Challenge

๐Ÿ‘‰ Add: 
โ€ข Toggle colors (switch back  forth)
โ€ข Count number of clicks
โ€ข Show alert message

๐Ÿ’ก Pro Tips

โ€ข Focus heavily on DOM + Events
โ€ข Practice small interactions daily
โ€ข Use browser console to test code

๐ŸŽฏ Outcome

After this: 
โœ” You can add interactivity 
โœ” You understand logic building 
โœ” Ready for Advanced JavaScript 

Double Tap โค๏ธ For More
  • โค 29
  • ๐Ÿ”ฅ 3
More from @webdevcoursefree
  1. Oct 14, 2026๐ŸŒ Web Development Roadmap โ€” Part 17 HTML Images โ€” <img> Tag Images make webpages more visโ€ฆ
  2. Oct 13, 2026๐—ง๐—ข๐—ฃ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ข๐—จ๐—ฅ๐—ฆ๐—˜๐—ฆ ๐—ง๐—ข ๐—•๐—ข๐—ข๐—ฆ๐—ง ๐—ฌ๐—ข๐—จ๐—ฅ ๐—ฆ๐—ž๐—œ๐—Ÿ๐—Ÿ๐—ฆ ๐—œ๐—ก ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ! Explorโ€ฆ
  3. Oct 12, 2026For example: Go to Profile โ†’ <a> Submit Form โ†’ <button> Open Article โ†’ <a> Delete Accountโ€ฆ
  4. Oct 12, 2026๐ŸŒ Web Development Roadmap โ€” Part 16 HTML Links โ€” Tag Links are one of the most importantโ€ฆ
  5. Oct 12, 2026๐Ÿš€ ๐—ช๐—ต๐—ถ๐—ฐ๐—ต ๐—ง๐—ฒ๐—ฐ๐—ต ๐—ฆ๐—ธ๐—ถ๐—น๐—น ๐—ช๐—ถ๐—น๐—น ๐—ฌ๐—ผ๐˜‚ ๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ? Want to builโ€ฆ
  6. Oct 9, 2026Post #4079
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’