I have a table with a column that has $ signs and i want all the $ signs removed and just leave the raw number
setup a fiddle - https://jsfiddle.net/ryc84j6n/
not sure why neither of these wont work
$('td.salary').each(function() {
//$(this).text().replace(/[^\d\.]/g, '');
$(this).text().replace("$", "");
});
html
<td >$1</td>
CodePudding user response:
You have to set the text to the new value.
$('td.salary').each(function() {
$(this).css("background-color","red");
let textWithoutDollarSign = $(this).text().replace("$", "");
$(this).text(textWithoutDollarSign);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table align="center" cellspacing="1" id="roster">
<caption><span><a title="Franchise home page, Record: 0-0-0, PF: 78.06" href="https://www48.myfantasyleague.com/2022/options?L=51913&F=0002&O=07">Franchise 2</a></span></caption>
<tbody>
<tr>
<th >Player</th>
<th >Pts</th>
<th >Bye</th>
<th >Salary</th>
<th >Notes</th>
<th >Year Signed</th>
<th >Acq.</th>
</tr>
<tr >
<td ><a href="player?L=51913&P=15252" title="Salary: $3, Notes: RFA, Year Signed: 2022, Week 17: vs Jaguars Sun 1:00 p.m. ET" >Mills, Davis HOU QB<img src="https://www.mflscripts.com/ImageDirectory/script-images/newsNew.svg" alt="new news" style="cursor:pointer;pointer-events:all;" title="new news" ></a></td>
<td ><a href="https://www48.myfantasyleague.com/2022/options?L=51913&O=08&PLAYER_ID=15252&YEAR=2022">10.38</a></td>
<td >6</td>
<td >$3</td>
<td >RFA</td>
<td >2022</td>
<td >5.06</td>
</tr>
<tr >
<td ><a href="player?L=51913&P=15698" title="Salary: $1, Notes: UFA, Year Signed: 2022, Week 17: at Raiders Sun 4:05 p.m. ET" >Purdy, Brock SFO QB<img src="https://www.mflscripts.com/ImageDirectory/script-images/newsOld.svg" alt="recent news" style="cursor:pointer;pointer-events:all;" title="recent news" ></a> (R) </td>
<td ><a href="https://www48.myfantasyleague.com/2022/options?L=51913&O=08&PLAYER_ID=15698&YEAR=2022">18.06</a></td>
<td >9</td>
<td >$1</td>
<td >UFA</td>
<td >2022</td>
<td >BB $173</td>
</tr>
<tr >
<td ><a href="player?L=51913&P=9431" title="Salary: $2, Notes: RFA, Year Signed: 2021, Week 17: at Chargers Sun 4:25 p.m. ET" >Stafford, Matthew LAR QB<img src="https://www.mflscripts.com/ImageDirectory/script-images/newsNone.svg" alt="no news" style="cursor:pointer;pointer-events:all;" title="no news" ></a> (<span title="IR">I</span>)</td>
<td > ‐ </td>
<td >7</td>
<td >$2</td>
<td >RFA</td>
<td >2021</td>
<td >4.16 (2021)</td>
</tr>
<tr >
<td ><a href="player?L=51913&P=15719" title="Salary: $1, Notes: UFA, Year Signed: 2022, Week 17: vs Dolphins Sun 1:00 p.m. ET" >Harris, Kevin NEP RB<img src="https://www.mflscripts.com/ImageDirectory/script-images/newsOld.svg" alt="recent news" style="cursor:pointer;pointer-events:all;" title="recent news" ></a> (R) </td>
<td > ‐ </td>
<td >10</td>
<td >$1</td>
<td >UFA</td>
<td >2022</td>
<td >BB $0</td>
</tr>
<tr >
<td ><a href="player?L=51913&P=15717" title="Salary: $3, Notes: RFA, Year Signed: 2022, Week 17: vs Jaguars Sun 1:00 p.m. ET" >Pierce, Dameon HOU RB<img src="https://www.mflscripts.com/ImageDirectory/script-images/newsNone.svg" alt="no news" style="cursor:pointer;pointer-events:all;" title="no news" ></a> (R) (<span title="IR">I</span>)</td>
<td > ‐ </td>
<td >6</td>
<td >$3</td>
<td >RFA</td>
<td >2022</td>
<td >1.06</td>
</tr>
<tr >
<td ><a href="player?L=51913&P=15709" title="Salary: $3, Notes: RFA, Year Signed: 2022, Week 17: vs Rams Sun 4:25 p.m. ET" >Spiller, Isaiah LAC RB<img src="https://www.mflscripts.com/ImageDirectory/script-images/newsNone.svg" alt="no news" style="cursor:pointer;pointer-events:all;" title="no news" ></a> (R) </td>
<td > ‐ </td>
<td >8</td>
<td >$3</td>
<td >RFA</td>
<td >2022</td>
<td >2.06</td>
</tr>
<tr >
<td ><a href="player?L=51913&P=15710" title="Salary: $3, Notes: RFA, Year Signed: 2022, Week 17: at Chargers Sun 4:25 p.m. ET" >Williams, Kyren LAR RB<img src="https://www.mflscripts.com/ImageDirectory/script-images/newsOld.svg" alt="recent news" style="cursor:pointer;pointer-events:all;" title="recent news" ></a> (R) </td>
<td ><a href="https://www48.myfantasyleague.com/2022/options?L=51913&O=08&PLAYER_ID=15710&YEAR=2022">0.60</a></td>
<td >7</td>
<td >$3</td>
<td >RFA</td>
<td >2022</td>
<td >8.06</td>
</tr>
<tr >
<td ><a href="player?L=51913&P=14840" title="Salary: $2, Notes: RFA, Year Signed: 2021, Week 17: at Raiders Sun 4:05 p.m. ET" >Aiyuk, Brandon SFO WR<img src="https://www.mflscripts.com/ImageDirectory/script-images/newsOld.svg" alt="recent news" style="cursor:pointer;pointer-events:all;" title="recent news" ></a></td>
<td ><a href="https://www48.myfantasyleague.com/2022/options?L=51913&O=08&PLAYER_ID=14840&YEAR=2022">26.70</a></td>
<td >9</td>
<td >$2</td>
<td >RFA</td>
<td >2021</td>
<td >2.16 (2021)</td>
</tr>
<tr >
<td ><a href="player?L=51913&P=13172" title="Salary: $1, Notes: UFA, Year Signed: 2022, Week 17: at Titans Thu 8:15 p.m. ET" >Brown, Noah DAL WR<img src="https://www.mflscripts.com/ImageDirectory/script-images/newsOld.svg" alt="recent news" style="cursor:pointer;pointer-events:all;" title="recent news" ></a></td>
<td ><a href="https://www48.myfantasyleague.com/2022/options?L=51913&O=08&PLAYER_ID=13172&YEAR=2022">1.70</a></td>
<td >9</td>
<td >$1</td>
<td >UFA</td>
<td >2022</td>
<td >BB $77</td>
</tr>
<tr >
<td ><a href="player?L=51913&P=15779" title="Salary: $3, Notes: RFA, Year Signed: 2022, Week 17: vs Vikings Sun 4:25 p.m. ET" >Doubs, Romeo GBP WR<img src="https://www.mflscripts.com/ImageDirectory/script-images/newsOld.svg" alt="recent news" style="cursor:pointer;pointer-events:all;" title="recent news" ></a> (R) </td>
<td ><a href="https://www48.myfantasyleague.com/2022/options?L=51913&O=08&PLAYER_ID=15779&YEAR=2022">5.00</a></td>
<td >14</td>
<td >$3</td>
<td >RFA</td>
<td >2022</td>
<td >2.11</td>
</tr>
<tr >
<td ><a href="player?L=51913&P=14127" title="Salary: $2, Notes: RFA, Year Signed: 2021, Week 17: vs Dolphins Sun 1:00 p.m. ET" >Meyers, Jakobi NEP WR<img src="https://www.mflscripts.com/ImageDirectory/script-images/newsNew.svg" alt="new news" style="cursor:pointer;pointer-events:all;" title="new news" ></a> (<span title="Questionable">Q</span>)</td>
<td ><a href="https://www48.myfantasyleague.com/2022/options?L=51913&O=08&PLAYER_ID=14127&YEAR=2022">16.80</a></td>
<td >10</td>
<td >$2</td>
<td >RFA</td>
<td >2021</td>
<td >9.01 (2021)</td>
</tr>
<tr >
<td ><a href="player?L=51913&P=15762" title="Salary: $3, Notes: RFA, Year Signed: 2022, Week 17: at Ravens Sun 8:20 p.m. ET" >Pickens, George PIT WR<img src="https://www.mflscripts.com/ImageDirectory/script-images/newsOld.svg" alt="recent news" style="cursor:pointer;pointer-events:all;" title="recent news" ></a> (R) </td>
<td ><a href="https://www48.myfantasyleague.com/2022/options?L=51913&O=08&PLAYER_ID=15762&YEAR=2022">4.90</a></td>
<td >9</td>
<td >$3</td>
<td >RFA</td>
<td >2022</td>
<td >1.11</td>
</tr>
<tr >
<td ><a href="player?L=51913&P=14992" title="Salary: $1, Notes: UFA, Year Signed: 2022, Week 17: vs Saints Sun 1:00 p.m. ET" >Watkins, Quez PHI WR<img src="https://www.mflscripts.com/ImageDirectory/script-images/newsNew.svg" alt="new news" style="cursor:pointer;pointer-events:all;" title="new news" ></a></td>
<td ><a href="https://www48.myfantasyleague.com/2022/options?L=51913&O=08&PLAYER_ID=14992&YEAR=2022">0.00</a></td>
<td >7</td>
<td >$1</td>
<td >UFA</td>
<td >2022</td>
<td >FCFS</td>
</tr>
<tr >
<td ><a href="player?L=51913&P=14137" title="Salary: $1, Notes: UFA, Year Signed: 2022, Week 17: vs Jets Sun 4:05 p.m. ET" >Fant, Noah SEA TE<img src="https://www.mflscripts.com/ImageDirectory/script-images/newsNew.svg" alt="new news" style="cursor:pointer;pointer-events:all;" title="new news" ></a> (<span title="Questionable">Q</span>)</td>
<td ><a href="https://www48.myfantasyleague.com/2022/options?L=51913&O=08&PLAYER_ID=14137&YEAR=2022">6.00</a></td>
<td >11</td>
<td >$1</td>
<td >UFA</td>
<td >2022</td>
<td >BB $101</td>
</tr>
<tr >
<td ><a href="player?L=51913&P=11647" title="Salary: $2, Notes: RFA, Year Signed: 2022, Week 17: vs Browns Sun 1:00 p.m. ET" >Thomas, Logan WAS TE<img src="https://www.mflscripts.com/ImageDirectory/script-images/newsOld.svg" alt="recent news" style="cursor:pointer;pointer-events:all;" title="recent news" ></a></td>
<td ><a href="https://www48.myfantasyleague.com/2022/options?L=51913&O=08&PLAYER_ID=11647&YEAR=2022">11.60</a></td>
<td >14</td>
<td >$2</td>
<td >RFA</td>
<td >2022</td>
<td >7.06</td>
</tr>
<tr >
<td ><a href="player?L=51913&P=13898" title="Salary: $1, Notes: UFA, Year Signed: 2022, Week 17: at Packers Sun 4:25 p.m. ET" >Joseph, Greg MIN PK<img src="https://www.mflscripts.com/ImageDirectory/script-images/newsOld.svg" alt="recent news" style="cursor:pointer;pointer-events:all;" title="recent news" ></a></td>
<td ><a href="https://www48.myfantasyleague.com/2022/options?L=51913&O=08&PLAYER_ID=13898&YEAR=2022">5.00</a></td>
<td >7</td>
<td >$1</td>
<td >UFA</td>
<td >2022</td>
<td >FCFS</td>
</tr>
<tr >
<td ><a href="player?L=51913&P=0506" title="Salary: $1, Notes: UFA, Year Signed: 2022, Week 17: vs Bills Mon 8:30 p.m. ET" >Bengals, Cincinnati CIN Def<img src="https://www.mflscripts.com/ImageDirectory/script-images/newsNone.svg" alt="no news" style="cursor:pointer;pointer-events:all;" title="no news" ></a></td>
<td > ‐ </td>
<td >10</td>
<td >$1</td>
<td >UFA</td>
<td >2022</td>
<td >FCFS</td>
</tr>
</tbody>
</table>