JavaScript · jQuery · Programming

A very simple jQuery plugin

A very simple plugin that changes the background color of an element on click. Plugin Code This is saved in a js file called myPlugin.js (function($) { //default options var defOption = {“bg”:”#f00″}; var finalOpt = {}; function makeBgRed(obj) { obj.style.backgroundColor = finalOpt.bg; } $.fn.myPlugin = function(option) { //util functions finalOpt = $.extend(defOption,option); //here ‘this’… Continue reading A very simple jQuery plugin