How to use return


#1

Hello, these two code have same result.
What's the difference between them.

var main = function() {
  $("#top-text").keyup(function(){
  	var topText = $("#top-text").val();
    $(".top-caption").text(topText);
  });
};

$(document).ready(main);
``` 
```
var main = function() {
  $("#top-text").keyup(function(){
  	var topText = $("#top-text").val();
    $(".top-caption").text(function(){
      return topText;
    });
  });
};
 
$(document).ready(main);

#2

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