I had an assignment to make a To Do list in HTML/JS/CSS
I am allowed to make any aesthetic changes as I want as long as it has 3 things: a button that allows the user to input to the list, removing the button when there is no input (white space is not considered input) and the user should be able to click on something so the user can delete the task.
I was thinking of a check box that was clicked for more than 5 seconds. so far I got this:
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="ToDo.css" type="text/css" />
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="ToDo.js"></script>
</head>
<body>
<h1>ToDo</h1>
<input type="checkbox"/>
<input type="text" placeholder="Please Enter a Task" id="input">
<input type="submit" value="Add" id="addButton" hidden="hidden">
</body>
</html>
And this is my JS file:
$(document).ready(function() {
$("#input")[0].oninput = function isEmpty() {
if ($("#input").val() == "") {
$("#addButton").fadeOut(250);
} else {
$("#addButton").fadeIn(250);
}
}
$("#addButton").click(function() {
$("#addButton").after($("<p></p>").text($("#input").val()));
//$("p:first").prepend('<input type="checkbox" value="102" name="tags[]" id="tag102" class="checkbox" />');
$("#input").val("");
$("#addButton").hide();
});
$('input[type=checkbox]').change(function() {
if( $(this).is(':checked')) {
alert("This passed");
}else {
alert("This failed");
}
});
});
I have a CSS files as well, but I am assuming that isn't important at the moment. I havn't started with the timer because I couldn't figure out how to check if the check box was checked. I tried using a regular HTML check box to check it out and that worked fine. but for some reason the ones crated through java script aren't working.
Please help, Thank you.
$("input[type='checkbox']").prop('checked');$(document).on("change", "input[type=checkbox]", function() { /* code */ })to bind event listeners to new elements.