coder25
coder25

Reputation: 2393

hide textarea in jquery

jquery

$(document).ready(function() {

    $('#postcomment').hide();
    $('#createtopic').click(function() {
        var text = $('#editor1').val();

        $.ajax({    
            type: "post",   
            url: "Handler/Topic.ashx",

            data: "text=" + text,
            success: function(msg) {
                $("#result").html(msg).fadeIn("fast");
            }
        });

        return false;
    });

    $('#postcomment').show();
});​

html

 <textarea id="postcomment" cols="50" rows="3" style="padding:5px;" 
  name="postcomment" >   </textarea>

I am unable to hide the textarea. Is it a wrong approah to hide a textarea?

Upvotes: 0

Views: 12054

Answers (2)

gdoron
gdoron

Reputation: 150313

It's working fine for me, Fiddle

Things to check:

  • Make sure you included jQuery scripts.
  • Check if you have errors in the console.
  • Maybe that textarea wasn't rendered when the DOM ready
  • There is some other code\css that override that hide() action?

Update: (After the full code added)

The last option is the winner... You override the hide with show in the last line:

$('#postcomment').show();

Remove it please...

Upvotes: 5

Amritpal Singh
Amritpal Singh

Reputation: 1785

     $("#postcomment").css("visibility", "hidden");

Upvotes: 0

Related Questions