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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:41:02+00:00 2026-05-30T01:41:02+00:00

I am theming a JSP app that has a table header with dynamically generated

  • 0

I am theming a JSP app that has a table header with dynamically generated data (I think it’s called Jasper Reports?) and I don’t have access to any template files for the output. I’ve gotten things to look pretty good with a little JQuery foo.

But I am still having one issue, there seems to be white space in some span tags within the headers td > spans:

<td><span> My Heading</span></td>

Note the white space before the word “My”.

I found this nifty bit of code to trim white space but the issue is that it takes all white space out.

var pane = $('span');
pane.val($.trim(pane.val()).replace(/\s*[\r\n]+\s*/g, '\n')
    .replace(/(<[^\/][^>]*>)\s*/g, '$1')
    .replace(/\s*(<\/[^>]+>)/g, '$1'));

So now using this code, it ends up as:

   <td><span>MyHeading</span></td>

Ideally I would like to modify it so just the first bit of white space is removed but none after 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-30T01:41:04+00:00Added an answer on May 30, 2026 at 1:41 am

    Use .text() to get the string value.

    var pane = $('span');
    pane.html($.trim(pane.text()));
    

    http://jsfiddle.net/gaboesquivel/cHevR/

    Edit:
    the above code won’t work as it overwrites the text if it there’s more than 1 span in the document

    You need to iterate the array of spans

    //array of all the spans that are children of a td element
    var spansArray = $('td > span');
    //iterate the array
    spansArray.each(function() {
        var $this = $(this);
        $this.html($.trim($this.text()));
    });​
    

    http://jsfiddle.net/gaboesquivel/cHevR/2/

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

Sidebar

Related Questions

I have a table that needs some custom theming. It has a lot of
I am creating a new plone.app.theming (Diazo) theme for my site. My rules.xml has
Magento has a fallback mechanism that helps prevent errors and theming problems by checking
I have a Plone site, themed with plone.app.theming. The problem I have is that
I'm looking for a simple, transparent checkbox component that properly supports XP/Vista/7 theming. It
Has anyone got an thoughts on how to handle theming a WSS site for
I've been fiddling around with drupal theming quite succesfully (or at least, that's what
I am trying to organize my theme folder, which has node theming overrides for
I am making a website that uses nothing but jquery-ui for theming. Well, in
I've used the Views Theming Wizard to output a template and it gave me

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.