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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:46:53+00:00 2026-05-15T00:46:53+00:00

This works fine in FireFox: $(#listname).val().trim() But in safari it errors: $(#listname).val().trim() while this

  • 0

This works fine in FireFox:
$(“#listname”).val().trim()

But in safari it errors: $(“#listname”).val().trim() while this does work, $(“#listname”).val()

Why is that?

  • 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-15T00:46:54+00:00Added an answer on May 15, 2026 at 12:46 am

    There’s no intrinsic trim function on strings. jQuery does define $.trim, but you use it like this:

    $.trim($("#listname").val())
    

    E.g., you pass the string into it, rather than calling it from a property on String.

    And as the other answerer mentioned, if you like, you can add it to all Strings (although I’d leverage jQuery’s function rather than doing my own regexs, because of Unicode vagaries in browsers):

    if (!String.prototype.trim) {
        String.prototype.trim = (function() {
            function String_trim() {
                return jQuery.trim(this);
            }
            return String_trim;
        })();
    }
    

    I’ve used a named function there (I always use named functions), but you could use fewer lines of code if you’re not bothered:

    if (!String.prototype.trim) {
        String.prototype.trim = function() {
            return jQuery.trim(this);
        };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a problem where firefox works just fine, while chrome has the problem.
This code works fine in Chrome. However, in Firefox, when it hits the GMxhr
I've prepared this demo: https://dl.dropbox.com/u/7224702/lists-bug.html It works fine in Firefox, Chrome and IE8 but
I have this authnav='<li class=last><a href=auth/login>login</a></li>'+ '<li><a href=auth/create_account>create account</a></li>'; It works fine in Firefox,
I have a Firefox 3.6.2 problem (3.5.x works just fine). This is the code:
This works fine: GET /mvc/Movies/TitleIncludes/Lara%20Croft When I submit a request that contains a colon,
This works fine: TreeMap <String, ArrayList> x_probs_org = new TreeMap<String, ArrayList>(); But this: TreeMap
I have $('#structure').html(html); This works fine in FireFox. IE 8 doesn't display the html.
This works fine in Firefox and IE9 font-family: Arial Rounded MT, Arial, Helvetica, sans-serif;
Any CSS experts have a clue why this works fine in Firefox and latest

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.