I'm new to JQuery, and I'm struggling with methods creation.
I've the following code:
- (function($) {
- $.fn.changeRed = function() {
- return this.each(function() {
- $(this).css('background-color', 'red');
- }
- });
- })(jQuery);
- $(document).ready(function() {
- $('p').changeRed();
- });
In the HTML page I've a simple
- <p>Hello</p>
This not work. Can you figure why not?