checkboxlist - Checkbox on my To Do list isn't working -
i'm trying create simple list using javascript , html. whenever user checks check-box i'd check box's css change text decoration of line-through. while debugging figured function deletetodo isn't invoked event of change.
any ideas doing wrong?
var todo = ""; $(document).ready(function (){ $("button").on("click", addatodo); $("input[type='checkbox']").on("change", deletetodo()); }); function addatodo(){ var todo = $("input").val(); console.log(todo); $("div").append('<input type="checkbox"><p>' + todo + '</p><br/>'); } function deletetodo(){ if($(this).is(":checked")) { $("p").css("text-decoration","line-through"); } } <input type="text" placeholder="to do"/> <button>add do</button> <br> <div></div>
you haven't included jquery in code. put html <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script> before code.
as well, when button pressed, program doesn't know button pressed, , nothing in response. need add on-click listener button, so:
<buttononclick=addatodo()>add do</button>
Comments
Post a Comment