Clearing TODO


Cannot get the text to clear from Add Item Box

var template = function(text) {
  return '<p><input type="checkbox"><i class="glyphicon glyphicon-star"></i><span>' + text + '</span><i class="glyphicon glyphicon-remove"></i></p>';

var main = function() {
  $('form').submit(function() {
    var text = $('#todo').val();
    var html = template(text);
    return false;  



Hi Brian,

I'm not a jQuery whiz so I can't fully explain the "why" of this, but, from the docs, it looks like remove is good for removing a whole element. In this case you don't want to remove the element, just the text. I would try using val() to set the value of your #todo to "", like this:


I wouldn't be surprised if someone came along with a better solution. :smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.