-1

I am trying to use a piece of code that enables and disables textboxes on a button click. Someone has solved this previously enable and disable textbox by using button click . Their Demo works exactly the way I want but when I copy and paste the exact code onto my html it doesn't work. I even tried pasting it into a completely blank html page and it still doesn't work.. Any ideas why? Thanks.

Wilfredo P's code ---

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

http://jsfiddle.net/AvEP7/1/

Community
  • 1
  • 1
Dan_ENZ
  • 49
  • 1
  • 9

1 Answers1

0

This works fine for me, do you want the field to clear out on disable? If so, try this:

 $('#textfieldToClose').prop('disabled', true).val('')

http://jsfiddle.net/AvEP7/11/

superUntitled
  • 22,351
  • 30
  • 83
  • 110
  • Yea it works fine in fiddle but I just copied the exact code to my html and tried it and it doesn't work... Can't understand why – Dan_ENZ Oct 04 '14 at 01:07