-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71de65b
commit d2e64e9
Showing
6 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
*{ | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | ||
} | ||
body{ | ||
padding: 1rem; | ||
transition: .4s; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
header{ | ||
display: flex; | ||
justify-content: center; | ||
margin: 30px 0 30px 0; | ||
} | ||
header button{ | ||
padding: 15px; | ||
border-radius: 1rem; | ||
border: none; | ||
background-color: #e9e7ea; | ||
font-size: 15px; | ||
font-weight: bold; | ||
cursor: pointer; | ||
} | ||
|
||
#parent{ | ||
display: flex; | ||
flex-wrap: wrap; | ||
} | ||
h1{ | ||
color: white; | ||
text-align: center; | ||
margin: 10px 0 10px 0; | ||
text-shadow: 0 0 30px black; | ||
} | ||
h4{ | ||
color: #703888; | ||
font-size: 20px; | ||
font-weight: bold; | ||
text-align: center; | ||
} | ||
h6{ | ||
color: #1a5188; | ||
font-size: 18px; | ||
font-weight: bold; | ||
text-align: center; | ||
} | ||
p{ | ||
color: #149054; | ||
font-size: 16px; | ||
font-weight: bold; | ||
text-align: center; | ||
} | ||
.card{ | ||
border-radius: 1rem; | ||
box-shadow: 4px 4px 4px rgb(238, 237, 172); | ||
width: 200px; | ||
background-color: rgb(255, 254, 211); | ||
margin: 1rem auto; | ||
padding: 20px; | ||
transition: .4s; | ||
} | ||
.card:hover{ | ||
box-shadow: 0 0 20px rgb(192, 191, 110); | ||
flex-grow: .3; | ||
cursor: pointer; | ||
} | ||
.card p{ | ||
padding: 10px; | ||
margin: 10px; | ||
transition: .4s; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const data = [ | ||
{ name: 'Ishanvi', email: '[email protected]', city: 'Ghaziabad'}, | ||
{ name: 'Kshitiz', email: '[email protected]', city: 'Delhi'}, | ||
{ name: 'Asmit', email: '[email protected]', city: 'Kanpur'}, | ||
{ name: 'Arpit', email: '[email protected]', city: 'Jalaun'}, | ||
{ name: 'Anisha', email: '[email protected]', city: 'Ghaziabad'} | ||
]; | ||
|
||
const root = document.getElementById('parent'); | ||
|
||
data.forEach((elem) => { | ||
const newCard = document.createElement('div'); | ||
newCard.addEventListener("click", () => { | ||
newCard.style.backgroundColor = getRandomColor(); | ||
}); | ||
//setAttribute | ||
//classList.add | ||
newCard.className = 'card'; | ||
newCard.innerHTML = ` | ||
<h4>${elem.name}</h4> | ||
<h6>${elem.email}</h6> | ||
<p class='text'>${elem.city}</p> | ||
`; | ||
root.appendChild(newCard); | ||
}) | ||
|
||
const getRandomColor = () => { | ||
const randomRed = Math.floor(Math.random() * 255); | ||
const randomGreen = Math.floor(Math.random() * 255); | ||
const randomBlue = Math.floor(Math.random() * 255); | ||
return `rgb(${randomRed}, ${randomGreen}, ${randomBlue})`; | ||
} | ||
|
||
const body = document.querySelector('body'); | ||
const handleBgChange = () => { | ||
console.log("Button Clicked"); | ||
//Logic to change background color | ||
body.style.backgroundColor = getRandomColor();; | ||
} | ||
|
||
const textElement = document.querySelectorAll('.text'); | ||
textElement.forEach((p) => { | ||
p.addEventListener('click', (event) => { | ||
event.stopPropagation(); | ||
p.style.backgroundColor = getRandomColor(); | ||
},false); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Form Handling</title> | ||
</head> | ||
<body> | ||
<form action=""> | ||
<input type="text" | ||
onchange="handleTextChange(event)" | ||
onkeydown="handleKeyDown(event)" | ||
onkeyup="handleKeyUp(event)"> | ||
</form> | ||
|
||
<script src="formEvent.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const handleTextChange = (e) => { | ||
console.log(e); | ||
console.log("Change:",e.target.value); | ||
}; | ||
const handleKeyDown = (e) => { | ||
console.log(e); | ||
console.log("Key Down:",e.target.value); | ||
}; | ||
const handleKeyUp = (e) => { | ||
console.log(e); | ||
console.log("Key Up:",e.target.value); | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
<link rel="stylesheet" href="eventStyle.css"> | ||
</head> | ||
<body> | ||
<h1>Events in JS</h1> | ||
<header> | ||
<button onclick="handleBgChange()">Change Background</button> | ||
</header> | ||
<div id="parent"> | ||
<!-- | ||
<div class="card"> | ||
<h4>Name</h4> | ||
<h6>Email</h6> | ||
<p>City</p> | ||
</div> | ||
--> | ||
</div> | ||
<script src="events.js"></script> | ||
</body> | ||
</html> |