JQuery method plugin not working

JQuery method plugin not working

I'm new to JQuery, and I'm struggling with methods creation.

I've the following code:

  1. (function($) {
  2.   $.fn.changeRed = function() {
  3.     return this.each(function() {
  4.         $(this).css('background-color', 'red');
  5.       }
  6.     });
  7. })(jQuery);
  8. $(document).ready(function() {
  9.   $('p').changeRed();
  10. });
In the HTML page I've a simple
  1. <p>Hello</p>

This not work. Can you figure why not?