SMacFadyen
SMacFadyen

Reputation: 3165

How can I fadein/slidedown a textarea if a checkbox is clicked

I want to output a textarea based on a checkbox. I would like it to fadeIn or Slidedown, beneath the checkbox.

I have a checkbox controlling a input field with JS, like so:

function enable_text(status) {
    status = (status) ? false : true; //convert status boolean to text 'disabled'
    document.password.myFormName.disabled = status;
    }

Can this be done with jQuery for both input and textareas if checked? Which areas of jQuery API should I research?

Many thanks

Upvotes: 1

Views: 883

Answers (2)

Frederiek
Frederiek

Reputation: 1613

You could do it with the slideToggle()

See jsfiddle

Upvotes: 0

Riz
Riz

Reputation: 10246

$(function(){
  $('input.anycheckbox').live('click', function(){
    $('textarea.txt').slideToggle();
  });
});

Upvotes: 1

Related Questions