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) { =; } $.fn.myPlugin = function(option) { //util functions finalOpt = $.extend(defOption,option); //here ‘this’… Continue reading A very simple jQuery plugin

JavaScript · Programming

A sample jQuery plugin

An example of a simple jQuery plugin that does some basic form validation. The HTML The HTML is a simple one with just three form fields. <form id="prod_form" method="get" action="#"> <label for="prod-name">Product Name* :</label> <input type="text" name="prod-name" id="prod-name"/> <span class="error" id="prod-name-error"></span><br/> <br/> <label for="prod-quant">Product Quant* :</label> <input type="text" name="prod-quant" id="prod-quant"/> <span class="error" id="prod-quant-error"></span> <br/> <label… Continue reading A sample jQuery plugin

JavaScript · OOP · Programming

Understanding Self Executing Anonymous Functions

Anonymous function is one which has no reference name. For example: function (){}; Creating Self Executing Function Now if we want to make it self-executing then use the following syntax: 1) Wrap the anonymous function within a round brackets. ( function() {…} ) 2) Execute the function by adding the () in the end. (… Continue reading Understanding Self Executing Anonymous Functions

Database · Java · Programming · transaction

Database Transaction Basics using Java

A database transaction is a single unit of work. It is a set of operations that succeed or fail as a unit. Properties of a Transaction Every transaction must have the four properties known as ACID. Atomicity : All operations succeed or fail as a unit. Consistency : Any transaction must end with consistent state… Continue reading Database Transaction Basics using Java