Skip to content
Merged
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
94 changes: 77 additions & 17 deletions index.css
Original file line number Diff line number Diff line change
@@ -1,22 +1,82 @@
.body{
background-color: lightskyblue;
}
#button{
background-color: rgb(33, 33, 92) ;
color: white;
font-size: 50px;
padding: 15px 15px;
margin: 20px 20px;
* {
box-sizing: border-box
}

:root {
--main-color: #fff
}

body {
margin: 0;
font-family: sans-serif;
background: linear-gradient(130deg, #5f0dda, #225bde, #079cba, #079cba, #225bde, #5f0dda);
background-size: 1200% 1200%;
animation: AnimationName 10s ease-in-out infinite;
color: var(--main-color);
}

@keyframes AnimationName {
0% {
background-position: 0% 51%
}

50% {
background-position: 100% 50%
}

100% {
background-position: 0% 51%
}
}

.container {
max-width: 900px;
margin: 0 auto
}

.text-center {
text-align: center
}

.mt-4 {
margin-top: 4rem
}

.main-heading {
font-size: 3rem
}

.big-block {
display: flex;
align-items: center;
justify-content: space-around
}

#text {
font-size: 2rem;
padding: 5px 15px;
border-radius: 10px;
border: 2px solid rgba(0, 0, 0, 0.2);
outline: none
}
#text{
font-size: 50px;
padding: 15px 15px;
margin: 20px 20px;

#button {
background-color: rgb(33, 33, 92);
color: var(--main-color);
font-size: 2rem;
padding: 5px 15px;
border-radius: 10px;
border-width: 2px;
border-color: var(--main-color);
cursor: pointer;
outline: none
}
.bigblock{
display: flex;
flex-direction: row;
justify-content: space-around;

ul {

list-style-type: "▶"
}

li {
padding: 6px 10px
}
30 changes: 18 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="index.css">
</head>
<body class="body">
<div class="bigblock">
<div class="textbox"><input id="text" type="text" placeholder="Enter text here....">
<ul id="list">
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>

</div>
<div class="right"><button id="button" value=Add type="button"onclick="add()"> Add Item </button> </div>
</div>
<body>
<h1 class="main-heading text-center">JS Append Child</h1>
<div class="big-block container">
<div class="textbox"><input id="text" type="text" placeholder="Enter text here....">


</div>

<div class="right"><button id="button" value=Add type="button" onclick="add()"> Add Item </button> </div>
</div>

<script src="index.js"></script>
<div class="container mt-4">
<h2>Appended child will be added here</h2>
<ul id="list">
<li>This is a demo child 1</li>
</ul>
</div>

<script src="index.js"></script>
</body>

</html>
22 changes: 16 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
function add(){
var input=document.getElementById("text");
var li=document.createElement("LI");
li.innerHTML=input.value;
input.value=""
document.getElementById("list").appendChild(li);
let click = true

function add() {
let input = document.getElementById("text")

if (input.value == "") {
alert("Input field is empty")
return
}
if (click) {
document.getElementById('list').innerHTML = ''
}
click = false
let li = document.createElement("li")
li.innerHTML = input.value
input.value = ""
document.getElementById("list").appendChild(li)
}