www.webdeveloper.com
Results 1 to 3 of 3

Thread: How can I replace all “_“ in second td’s text of every row with a space using Jquery?

  1. #1
    Join Date
    Feb 2009
    Posts
    95

    How can I replace all “_“ in second td’s text of every row with a space using Jquery?

    Hi,
    I am getting the following html from a query result. Remember result is a string.
    Code:
    <table width=100% border=0 cellpadding=0 cellspacing=0><tr><th class=Sub>#</th><th class=Sub>File Name</th><th class=Sub>Size</th><th class=Sub>Date</th></tr><tr><td width=40 align=right class=Data1>1.</td><td class=Data1><a target=_blank href="/files/spool/404048/1075954/80_1267615_1075954/Sivaratnam_Suthakaran,_Dr._Peter_Cobrin,_Jan_20_2012,_IME_Guideline_Kit.pdf">Sivaratnam_Suthakaran,_Dr._Peter_Cobrin,_Jan_20_2012,_IME_Guideline_Kit.pdf</a>&nbsp;</td><td align=right width=85 class=Data1>22 KB</td><td align=right width=140 class=Data1>02/04/2012 8:5am</td></tr></table>
    How can I replace all “_“ in second td’s text of every row with a space using Jquery?
    Thanks

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>123</title>
    <head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script type="text/javascript">
    var str='<table width=100&#37; border=0 cellpadding=0 cellspacing=0><tr><th class=Sub>#</th><th class=Sub>File Name</th><th class=Sub>Size</th><th class=Sub>Date</th></tr><tr><td width=40 align=right class=Data1>1.</td><td class=Data1><a target=_blank href="/files/spool/404048/1075954/80_1267615_1075954/Sivaratnam_Suthakaran,_Dr._Peter_Cobrin,_Jan_20_2012,_IME_Guideline_Kit.pdf">Sivaratnam_Suthakaran,_Dr._Peter_Cobrin,_Jan_20_2012,_IME_Guideline_Kit.pdf</a>&nbsp;</td><td align=right width=85 class=Data1>22 KB</td><td align=right width=140 class=Data1>02/04/2012 8:5am</td></tr></table>';
    $(document).ready(function(){
    $('#result').html(str);
    $('#result a').each(function(){$(this).css('text-decoration','none');var t=$(this).text();$(this).text(t.replace(/_/g,' '));});
    });
    </script>
    </head>
    <body>
    <center>
    <div id="result"></div>
    </center>
    </body>
    </html>
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    Feb 2009
    Posts
    95
    Quote Originally Posted by Padonak View Post
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>123</title>
    <head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script type="text/javascript">
    var str='<table width=100% border=0 cellpadding=0 cellspacing=0><tr><th class=Sub>#</th><th class=Sub>File Name</th><th class=Sub>Size</th><th class=Sub>Date</th></tr><tr><td width=40 align=right class=Data1>1.</td><td class=Data1><a target=_blank href="/files/spool/404048/1075954/80_1267615_1075954/Sivaratnam_Suthakaran,_Dr._Peter_Cobrin,_Jan_20_2012,_IME_Guideline_Kit.pdf">Sivaratnam_Suthakaran,_Dr._Peter_Cobrin,_Jan_20_2012,_IME_Guideline_Kit.pdf</a>&nbsp;</td><td align=right width=85 class=Data1>22 KB</td><td align=right width=140 class=Data1>02/04/2012 8:5am</td></tr></table>';
    $(document).ready(function(){
    $('#result').html(str);
    $('#result a').each(function(){$(this).css('text-decoration','none');var t=$(this).text();$(this).text(t.replace(/_/g,' '));});
    });
    </script>
    </head>
    <body>
    <center>
    <div id="result"></div>
    </center>
    </body>
    </html>
    Thank you very much. This is what I want. U ROCK.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles