I want to truncate a text with DOTS using JavaScript

Discussion in 'JavaScript' started by Cyber Criminal, Jan 15, 2011.

  1. #1
    Hello,

    I'm looking for a simple script which can truncate a TEXT with DOTS (...)
    I did a search, but in vain. Any examples would be helpful.

    Thanks,
    CC.
     
    Cyber Criminal, Jan 15, 2011 IP
  2. Tanya Roberts

    Tanya Roberts Active Member

    Messages:
    250
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    #2
    <?php
    $content = "My name is shila.";
    $filter = "name";
    str_replace($filter,"...",$content);
    ?>

    output: My ... is shila.
     
    Tanya Roberts, Jan 15, 2011 IP
  3. Cyber Criminal

    Cyber Criminal Well-Known Member

    Messages:
    104
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    121
    #3

    I want to truncate using JavaScript, not with PHP. I'm OK with a CSS solution too.
     
    Cyber Criminal, Jan 15, 2011 IP
  4. hogan_h

    hogan_h Peon

    Messages:
    199
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #4
    hogan_h, Jan 15, 2011 IP
  5. mnvlxxx

    mnvlxxx Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Result: I want to truncate a...
     
    mnvlxxx, Jan 15, 2011 IP