SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Addict D3V4's Avatar
    Join Date
    May 2010
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with substring

    I have a series of elements which should appear only in the printed version of the page. Before doing so, though, I need to edit some of them removing some extra chars. This is how I've done it:

    Code:
    $(".print").each(function(i) {
    	$length = $(this).text().length;
    	$(this).text().substring(0,$length-5);
    })
    If I alert the second command inside the loop I see the correct substring. However, when I preview the printed page, I still see the original string. What am I missing?

  2. #2
    SitePoint Addict MrBaseball34's Avatar
    Join Date
    Sep 2002
    Location
    Round Rock, Texas
    Posts
    277
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Doesn't look like you are setting the value to the substring.
    MrBaseball34
    Hook'Em Horns!

  3. #3
    SitePoint Addict D3V4's Avatar
    Join Date
    May 2010
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do you mean?

  4. #4
    SitePoint Addict MrBaseball34's Avatar
    Join Date
    Sep 2002
    Location
    Round Rock, Texas
    Posts
    277
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You aren't changing the original string with the edited version.
    MrBaseball34
    Hook'Em Horns!

  5. #5
    SitePoint Addict D3V4's Avatar
    Join Date
    May 2010
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right, thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •