enable and disable textbox by using button click


I have multiple of textbox...each textbox have own button to enable or disable . How to do it ? I have already try this

$('#disablebutton').click(function(){ $('#textfieldToClose').attr('disable'); }); <input type="text" name="text11" readonly="readonly" id="textfieldToClose"> <input type="button" value="edit" name="button1" id="disablebutton">



$(document).ready(function(){ $('#disablebutton').click(function(){ if($('#textfieldToClose').prop('disabled')) { $('#textfieldToClose').prop('disabled', false) } else{ $('#textfieldToClose').prop('disabled', true) } }); })

or with Read only:

$(document).ready(function(){ $('#disablebutton').click(function(){ if($('#textfieldToClose').prop('readonly')) { $('#textfieldToClose').removeAttr('readonly'); } else{ $('#textfieldToClose').attr('readonly', 'readonly') } }); });

Because you only select the attr but, don't do anything with. <a href="http://jsfiddle.net/AvEP7/1/" rel="nofollow">Live demo</a>


Try this:

$('#disablebutton').click(function(){ $(this).prev().attr("disabled", "disabled"); });

<strong><a href="http://jsfiddle.net/NLvBT/" rel="nofollow">Working Demo</a></strong>


$('#disablebutton').click(function(){ $('#textfieldToClose').attr('disabled', 'disabled'); //sett the `disabled` attribute on the element });

$('#textfieldToClose').attr('disable') did not work because you were just quering an attribute disable on the element which doesn't even exist. The correct name is disabled


  • How to select all records from first table and only first matching record from second table?
  • Tkinter button 'not defined' when ran
  • I can't show LinearLayout at bottom to scroll view
  • Android Custom dialog inflating from layout - alignment issue
  • How to edit a Word document that opens in read-mode in VBA
  • DependencyObject.AssociatedObject is always null
  • countdown bar android example
  • How to getText() from the input field of an angularjs Application
  • Disable Kendo Autocomplete
  • FFmpeg Conversion Error
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • Fetching methods from BroadcastReceiver to update UI
  • How to check if every primary key value is being referenced as foreign key in another table
  • MySQL WHERE-condition in procedure ignored
  • Can I have the cursor start on a particular column by default in jqgrid's edit mode?
  • Symfony2: How to get request parameter
  • what is the difference between the asp.net mvc application and asp.net web application
  • jquery mobile loadPage not working
  • Web-crawler for facebook in python
  • GridView Sorting works once only
  • Matrix multiplication with MKL
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • WPF Applying a trigger on binding failure
  • trying to dynamically update Highchart column chart but series undefined
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • How do I configure my settings file to work with unit tests?
  • How to stop GridView from loading again when I press back button?
  • How to get Windows thread pool to call class member function?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • Busy indicator not showing up in wpf window [duplicate]
  • costura.fody for a dll that references another dll
  • Binding checkboxes to object values in AngularJs
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal