Friday, April 27, 2012

Disable Enable BUTTON using query

Disable Enable BUTTON using query :

Disable :
      Using Id :
             $('#ButtonId').attr('disabled', 'disabled');
      Using Class:
              $('.ButtonClass').attr('disabled', 'disabled');

Enable :
     Using Id :
              $('#ButtonId').removeAttr('disabled');
     Using Class:
              $('.ButtonClass').removeAttr('disabled');


Cheers,

Check defined variable exists or not in Javascript

How to check defined variable exists or not in Javascript :

There are few ways to check if any variable exists or not

1) if(typeof IdOfTheVariable != 'undefined')
     {
             //Do Something
      }

or

2) if(window.IdOfTheVariable === undefined)
    {
        //Do Something
    }


Cheers,