2

Possible Duplicate:
Jquery event on a disabled input

I am making an edit dialog for a device. The device has a comment-field in the database. This comment-field only has to be editable when the textarea representing it is not disabled.

I know by trial and error that

$("#textarea").click(function(){
// textarea will be enabled here
});

Doesn't work, since the textarea is disabled... is there a way around this or another way to add a click event to a disabled element?

EDIT:

James link worked. Event on a disabled input

One problem though. IE don't support position absolute on divs when are empty. If i fill the div with a color in CSS it displays, but if i don't and just set the top,bottom,left,right and position it wont't show.. anyone know a fix fore this? (im fine with it only working in FF for now)

thanks again

Community
  • 1
  • 1
Thor A. Pedersen
  • 1,122
  • 4
  • 18
  • 32

1 Answers1

5

you can make the text area readonly instead of disabled. it will have the same effect and will be clickable.

<textarea readonly=true>
    aaa
</textarea>

$("textarea").click(function(){
alert(123);
});
dov.amir
  • 11,489
  • 7
  • 45
  • 51