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

  • Home
  • SEARCH
  • 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 7538029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:00:29+00:00 2026-05-30T07:00:29+00:00

i have trouble with optimization of the code below which is changing css property

  • 0

i have trouble with optimization of the code below which is changing css property of some table cells after write or delete text from textarea

$('#par01par04text textarea').keyup(function() {
          var n = $(this).val().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');
          }
        });


        $('#par02par04text textarea').keyup(function() {
          var n = $(this).val().length;
          if (n > 0) {
            $('#par02TextComments.comments').css('display','table-cell');
            $('#par02LabelComments.comments').css('display','table-cell');
          }
          else if (n == 0){
            $('#par02TextComments.comments').css('display','none');
            $('#par02LabelComments.comments').css('display','none');
          }
        });


        $('#par03par04text textarea').keyup(function() {
          var n = $(this).val().length;
          if (n > 0) {
            $('#par03TextComments.comments').css('display','table-cell');
            $('#par03LabelComments.comments').css('display','table-cell');
          }
          else if (n == 0){
            $('#par03TextComments.comments').css('display','none');
            $('#par03LabelComments.comments').css('display','none');
          }

i wrote this code but there is an error “$(textarea) is not defined” i know i’m close, could any one can help me put it together

$.each(
      [
        { textarea: '#pom02par01UwagiText textarea', Text: '#pom02par01TextComments.comments', Label: '#pom02par01LabelComments.comments' },
        { textarea: '#pom02par02UwagiText textarea', Text: '#pom02par02TextComments.comments', Label: '#pom02par02LabelComments.comments' },
        { textarea: '#pom02par03UwagiText textarea', Text: '#pom03par02TextComments.comments', Label: '#pom02par03LabelComments.comments' },
        { textarea: '#pom02par04UwagiText textarea', Text: '#pom02par03TextComments.comments', Label: '#pom02par04LabelComments.comments' }
      ],
      function(index,value){       
        $(textarea).keyup(function() {
          var n = $(textarea).val().length;
          if (n > 0) {
            $(value.Text).css('display','table-cell');
            $(value.Label).css('display','table-cell');
          }
          else if (n == 0){
            $(value.Text).css('display','none');
            $(value.Label).css('display','none');
          }
        });
      }
    );
  • 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-30T07:00:30+00:00Added an answer on May 30, 2026 at 7:00 am

    You have to select the current item:

    ...
    function (index, value) {
        var me = $(value.textarea);
        me.keyup(function () { var n = me.val().length; ... });
    }
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have trouble understanding the underlying errors with the code below: class myClass {
I have trouble with the following piece of code. When I go through with
I have trouble where, for some reason, SVN would only merge the newly generated
I have trouble launching Glassfish v3 on Mac In Windows, after installation of Glassfish
I have trouble finding way to correctly refactor this code so that there would
I've just started learning Linux and I'm having some trouble disabling GCC's optimization for
I have trouble getting a flash message to show after a failed form submit.
I have trouble using SSL pages with JMeter, which I previously posted here .
I have some heavily templated c++ code that I am working with. I can
I have trouble mixing the C and C++ code , I separately compile the

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.