remove text in parentheses and the parentheses using .filter() or .slice()

Posted by liz on Stack Overflow See other posts from Stack Overflow or by liz
Published on 2010-04-10T23:48:34Z Indexed on 2010/04/10 23:53 UTC
Read the original article Hit count: 363

Filed under:
|

i have a table with code like this:

 <tr>
               <th scope="row">5-17</th>
               <td>23.6 (22.0-24.0)</td>
               <td>18.0 (17-20.0)</td>
           </tr>
           <tr>
               <th scope="row">Total 0-17</th>
               <td>20.6 (8-15.6)</td>
               <td>16.1 (22.2-24.0)</td>
           </tr>

i am using the following function to find the contents of the table cells and bring it into an array:

var l1 =   $('#datatable td:nth-child(2)').map(function() {
     return $(this).text();
    }).get();

the table fragment's id is "datatable".

this returns properly, however i am putting this array into jqPlot and it cant read the stuff between the parentheses or the parentheses themselves.

i need the data to remain in the table however because we are displaying both the table and the chart.

i cant reformat (add spans around the content i want to remove etc) because these tables are being generated by another piece of software.

i think what i need to do is either slice off after the space or use a regex to find and remove. not sure how to proceed with either of these. thanks!

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript