Reputation: 1840
Ok so I don't really understand what's happening with the example I'm about to show. I'm creating, or rather trying to create a jQuery plugin. I'm really new to programming and seem to run into a lot of walls.
The resource page I'm on is (http://learn.jquery.com/plugins/basic-plugin-creation/)
My question is this:
$.fn.greenify = function() {
this.css( "color", "green" );
};
$( "a" ).greenify(); // Makes all the links green.
From their site works.
Now my code:
$.fn.dark = function() {
this.addClass( ".panelDark");
};
$( ".panel" ).dark();
does not work. Can someone please help me on how to add classes in this fashion?
Attached is a jsFiddle I'm to show all the code.
Upvotes: 0
Views: 32
Reputation: 57095
Typo
this.addClass( "panelDark");
^ remove . from here
.addClass('ClassName') not .addClass('.ClassName')
Upvotes: 2