Created
July 19, 2020 13:23
-
-
Save ayan-b/0beaa26417bf3f73fff8230bbf4f14b3 to your computer and use it in GitHub Desktop.
jQuery TODO
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>jQuery Todo App</title> | |
<link data-require="[email protected]" data-semver="4.1.3" rel="stylesheet" | |
href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" /> | |
<script data-require="[email protected]" data-semver="4.1.3" | |
src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> | |
<script data-require="jquery" data-semver="3.2.1" | |
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script> | |
<script src="script.js"></script> | |
</head> | |
<body> | |
<div class="col-md-12"> | |
<h1>jQuery Todo App</h1> | |
<fieldset class="ui-grid-a"> | |
<div class="ui-block-a"> | |
<textarea placeholder="Enter task" id="input" cols="50" maxlength="128"></textarea> | |
</div> | |
<div class="ui-block-b"> | |
<input type="button" class="btn btn-outline-success" value="Add" id="add-btn" /> | |
</div> | |
</fieldset> | |
<br /> | |
<div data-role="content"> | |
<ul class="list-group" id="taskListSection"> | |
<li class="list-group-item active">Todos</li> | |
</ul> | |
<br /> | |
</div> | |
</div> | |
</body> | |
</html> |
This file contains hidden or 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
let count = 0; | |
$(function () { | |
$('#add-btn').click(function () { | |
let newTask = $('#input').val(); | |
if (newTask !== '') { | |
++count; | |
$('#taskListSection').append('<li class="list-group-item">' + '<button type="button" class="deletetask btn btn-outline-danger id="del-btn-' + count + '">Remove</button> ' + newTask + '</li>'); | |
$('#input').val(''); | |
$('.deletetask').click(function () { | |
$(this.parentNode).remove(); | |
}); | |
} else { | |
alert('Empty input not allowed!'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment