Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7498495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:29:46+00:00 2026-05-29T19:29:46+00:00

how to setting display:none to some div after I delete the text from textarea

  • 0

how to setting display:none to some div after I delete the text from textarea

i have this

$("#par02par04text textarea").keyup(function() {
    $('#par02TextComments.comments').css('display','table-cell');
    $('#par02LabelComments.comments').css('display','table-cell');
});

which setting display to the some element after I start typing in textarea, i want to invert this when I delete the text from textarea i want to setup display: none

i wrote this

$("#par01par04text textarea").keyup(function() {
    var n = $("td#par01TextComments").length;
    if (n > 0) {
        $('#par01TextComments.comments').css('display','table-cell');
        $('#par01LabelComments.comments').css('display','table-cell');
    }
    else if (n == 0){
        $('#par01TextComments.comments').css('display','none');
        $('#par01LabelComments.comments').css('display','none');
    }
}); 

but nothing happens

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T19:29:47+00:00Added an answer on May 29, 2026 at 7:29 pm

    When you do $("td#par01TextComments").length you are actually getting the length of the jquery object, not the value of the element you queried.

    Get first the value with .val() of the textarea and check the length

    $("#par01par04text textarea").keyup(function() {
        var n = $(this).val().length;
        ...
    });
    

    Note:

    You should not preprend an ID selector with the tagname (ex: td#someID) as it reduces its efficiency.

    The ID selector normally uses the native javascript function getElementById(). By prepending with the tagname, jquery is not able to use the native function and any other way then getElementById is less efficient.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I display a bunch of posts from users on a page. I have the
I have some HTML that looks like this: <ul class=faq> <li class=open> <a class=question
Here is some asp.net markup: <tr style=display:none id=AllInRateRow> <td id=td6> All-In Fixed Rate <span
I have a radpanel, and inside there I have a div with some data
I need some help to get this to work. It works, but i have
I have some jQuery styled to fade in my logo and nav. This works
<html> <style type=text/css> a { display: none; } </style> <body> <p id=p> a paragraph
I have configured WordPress to display a static front page as described here: http://codex.wordpress.org/Settings_Reading_SubPanel#Reading_Settings
Setting up ASP.net MVC with Linq2SQL or Entity Framework's context to have scaffolding work
I have strange discarding behavior of struts2 while setting cache option for my image.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.