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 7924727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:53:46+00:00 2026-06-03T17:53:46+00:00

How do I get this done. I am trying to append text to a

  • 0

How do I get this done. I am trying to append text to a text area. If some value already exists then append. I had it working but seems like it cannot work in all browsers. Is there a better way to do this?

Tried both ways, they don’t work in Chrome, IE and FF –

if ($('#log').value == undefined) {
$('#log').val("First: " + result[0]);
} else {
$('#log').val($('#log').value += "Second: " + result[0]);
}

if ($('#log').value == undefined) {
$('#log').val("First: " + result[0]);
} else {
$('#log').val(log.value += "Second: " + result[0]);
}

Without If, this works in Chrome but not in IE and FF –

$('#log').val(log.value += "First: + result[0]);
  • 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-06-03T17:53:49+00:00Added an answer on June 3, 2026 at 5:53 pm

    jQuery objects don’t have a .value property, so $('#log').value will always be undefined. This means that your statement will always call $('#log').val("First: " + result[0]); and never call the second one.

    You need to check if($('#log').val() == '') instead.

    As for .val(), you can pass a function. This function will be passed the current value of the input.

    if ($('#log').val() == '') {
        $('#log').val("First: " + result[0]);
    } else {
        $('#log').val(function(i, v){ // v is the current value
            return v + "Second: " + result[0];  // what's returned is what the value will be set to
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get this done in a C++ program on Windows, using visual
I want to get this straight. I know what DLL's are. I have done
I have a large table that get populated from a view. This is done
I get this error when trying ruby script/console Rails requires RubyGems >= . Please
I get this error when trying to link a win32 exe project. I have
I'm trying to append a value only if a condition is met (distance !=
I'm trying to use this query to delete the rows that are already on
I'm trying to get cdata text from a node using dom4j java. My issue
I am trying to run the following script, but get the error IndexError: list
I'm trying to store in a database some GPS data that I get from

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.