Disable functionality with jquery -a simple approach

. Wednesday, October 24, 2012
  • Agregar a Technorati
  • Agregar a Del.icio.us
  • Agregar a DiggIt!
  • Agregar a Yahoo!
  • Agregar a Google
  • Agregar a Meneame
  • Agregar a Furl
  • Agregar a Reddit
  • Agregar a Magnolia
  • Agregar a Blinklist
  • Agregar a Blogmarks

Hi Guys,
How can you disable any control with particular Id/class etc of html, with jquery its fairly very simple
create a method which will disable the control.
Note : that the disable method is not jquery's method . Its a custom method (command) created for our application use.
 
(function ($) {
   $.fn.disable = function () {
       return $(this).each(function () { 
            $(this).attr('disabled', 'disabled'); 
       });
    };

Now access the element with Id(in my case)

 
var input = $('#txtname');
// Disable all the controls having
input.disable();

body of html appear like this

 
             
                

as all of you know now i'm using git so please download the complete example from here

0 comments: