Build an Expense Tracker using HTML, CSS & JavaScript π°
π° Build an Expense Tracker using HTML, CSS & JavaScript
Hello everyone π
Welcome back!
In this beginner-friendly project, we will build an Expense Tracker using HTML, CSS & JavaScript π»
This project helps you learn:
- DOM Manipulation
- JavaScript Logic
- Dynamic Updates
- Balance Calculation
Perfect for beginners π
---
π Features of Expense Tracker
✔ Add Income & Expenses
✔ Dynamic Balance Calculation
✔ Delete Transactions
✔ Responsive UI
✔ Beginner-friendly project
---
π§± Step 1: HTML Code
HTML
<!DOCTYPE html>
<html>
<head>
<title>Expense Tracker</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Expense Tracker</h1>
<h2 id="balance">Balance: ₹0</h2>
<input type="text" id="text"
placeholder="Enter description">
<input type="number" id="amount"
placeholder="Enter amount">
<button onclick="addTransaction()">
Add Transaction
</button>
<ul id="list"></ul>
</div>
<script src="script.js"></script>
</body>
</html>
---
π¨ Step 2: CSS Code
CSS
*{
margin:0;
padding:0;
box-sizing:border-box;
font-family:Arial;
}
body{
height:100vh;
display:flex;
justify-content:center;
align-items:center;
background:linear-gradient(135deg,#11998e,#38ef7d);
}
.container{
background:white;
padding:30px;
width:400px;
border-radius:15px;
text-align:center;
box-shadow:0 10px 25px rgba(0,0,0,0.2);
}
h1{
margin-bottom:20px;
}
input{
width:100%;
padding:12px;
margin:10px 0;
border:2px solid #ddd;
border-radius:8px;
}
button{
width:100%;
padding:12px;
background:#007bff;
color:white;
border:none;
border-radius:8px;
cursor:pointer;
}
ul{
list-style:none;
margin-top:20px;
}
li{
background:#f4f4f4;
padding:10px;
margin:10px 0;
border-radius:8px;
}
---
⚡ Step 3: JavaScript Code
JavaScript
let balance = 0;
function addTransaction(){
const text =
document.getElementById("text").value;
const amount =
parseFloat(document.getElementById("amount").value);
if(text === "" || isNaN(amount)){
alert("Please enter valid details");
return;
}
balance += amount;
document.getElementById("balance").innerText =
`Balance: ₹${balance}`;
const li =
document.createElement("li");
li.innerText =
`${text} : ₹${amount}`;
document.getElementById("list")
.appendChild(li);
document.getElementById("text").value = "";
document.getElementById("amount").value = "";
}
---
π― What You Will Learn
✅ DOM Manipulation
✅ Dynamic Balance Updates
✅ JavaScript Functions
✅ Event Handling
✅ Real-world Project Logic
---
⭐ Tips to Improve Project
π Add Delete Button π️
π Add Income & Expense Categories π³
π Add Local Storage πΎ
π Add Charts π
---
π Conclusion
This was an Expense Tracker Project using JavaScript π°
A perfect beginner project to improve your frontend and JavaScript skills π
---
π’ Also Read
π Password Generator Project
π Quiz App Project
π Weather App Project
---
π Save and share this project π
π Follow for more coding content π»
Comments
Post a Comment