Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[001] Counter App #112

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions 001-counter-app/Sakib/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Counter App</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>

</head>

<body class="bg-gray-100 flex items-center justify-center min-h-screen">

<!-- Counter App Container -->
<div class="bg-white shadow-lg rounded-lg p-8 text-center">
<h1 id="title" class="text-2xl font-bold text-gray-800 mb-4"> </h1>

<!-- Counter Display -->
<div id="counter" class="text-4xl font-bold text-gray-700">0</div>

<!-- Counter Controls -->
<div class="mt-6">
<button id="increment"
class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded mr-2">+</button>
<button id="decrement" class="bg-red-500 hover:bg-red-600 text-white font-bold py-2 px-4 rounded ml-2">-</button>
</div>
</div>
<script src="/vanilla-javascript-fall-2024/001-counter-app/Sakib 2.2/script.js"></script>


</body>

</html>
67 changes: 67 additions & 0 deletions 001-counter-app/Sakib/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
console.log(" nazmus sakib");
var count =0;
function setapplicationtitle()
{
const titleElement =document.getElementById('title');
console.log(titleElement);
titleElement.innerText="Counter App";
}
setapplicationtitle();
const incrementButton = document.getElementById('increment');
// --- this part of code is for showing alert when + Button is clicked !!!
// function increaseCount()
// {
// alert(' Increase Button Clicked!!!');
// }
// incrementButton.addEventListener('click',increaseCount);

const countshow= document.getElementById('counter');
function increaseCount()
{
if(count>=10)
{
alert('OverFlow !!!!');
}
else
{
count=count+1;
countshow.innerText=count;
}

}
incrementButton.addEventListener('click',increaseCount)

const decrementButton =document.getElementById('decrement');


// --- this part of code is for showing alert when - Button is clicked !!!
// function decreseCount()
// {
// alert('Decrese Button Clicked !!!');
// }
// decrementButton.addEventListener('click',decreseCount);

const showdecrement=document.getElementById('counter');
function decrementCount()
{
if(count===0)
{
alert("Negative Value is not acceptable !!!!");
}
else
{
count=count-1;
showdecrement.innerText=count;
}

}

decrementButton.addEventListener('click',decrementCount);



// const counterElement=document.getElementById('counter');
// counterElement.innerText=3;