Why 'return false'?


I'd like to know, why do we need a "return false" at the end of the main function, do we want to prevent the form from being submitted? why should we do that?

Also can someone please help to check if my code is correct? Cheers.

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;  

  'click', '.glyphicon-star', function(click) {

  'click', '.glyphicon-remove',function(click){



Hi @maylzh,

return false prevents the form from being submitted and refreshing the page, which causes the entry to be lost :slight_smile:


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