asdf
asdf

Reputation: 57

jQuery Text Replace

Have some text that needs to be replaced, searched around this website for all results with similar titles and no luck.

Currently the text is Handling Fee: and I need it to say Shipping Insurance: - Please Help!

Here's the html output of the page;

<div class="c3 right">       
    <h2>Order Summary</h2>
    <table class="styledtable">
        <thead>
        <tr>
            <th>Quantity</th>

            <th>Product</th>
            <th>Price</th>
            <th>Total</th>
        </tr>
        </thead>
        <tbody>

                <tr>

                    <td style="text-align:center">1</td>
                    <td><strong>ACT Clutch Kit - Heavy Duty (HD) (DC1-HDSS)</strong>
<div class="order_item_notes">HD Clutch Kit<br/> Performance Street Disc (SS)</div>
<div class="order_item_specs">
Components : D018, 3001532, ATCP23<br/>
</div>
 </td>
                    <td style="text-align:right">$314.25</td>

                    <td style="text-align:right">$314.25</td>
                </tr>


        <tr>
            <td colspan="3" style="text-align:right">Items Total</td>
            <td style="text-align:right">$<span id="itemstotal">314.25</span></td>
        </tr>
        <tr>

            <td colspan="3" style="text-align:right">Shipping:</td>
            <td style="text-align:right">$<span id="shippingtotal">TBD</span></td>
        </tr>

        <tr>
            <td colspan="3" style="text-align:right">Handling Fee:</td>
            <td style="text-align:right">$<span id="handlingfee">0.00</span></td>

        </tr>

        <tr>
            <td colspan="3" style="text-align:right">Tax:</td>
            <td style="text-align:right">$<span id="taxtotal">0.00</span></td>
        </tr>
        <tr>
            <td colspan="3" style="text-align:right">Order Total:</td>

            <td style="text-align:right">$<span id="total">0.00</span></td>
        </tr>
        </tbody>            
    </table>

    <p>Upon checkout, you <strong>must enter</strong> your cars <strong>year, make and model</strong> into the comments section at the bottom of this page.&nbsp;<strong> We will not complete your order if we do not have this information!</strong></p>

<p>&nbsp;</p>
</div>
</div> 

Upvotes: 2

Views: 8779

Answers (3)

Variant
Variant

Reputation: 17385

You can use a jQuery :contains selector:

$("td:contains('Handling Fee:')").text("Shipping Insurance:");

You can see it in action here: http://jsfiddle.net/cnhYj/

Update

in order to get it to work after the document is ready you can write it like that:

$(function() {
    $("td:contains('Handling Fee:')").text("Shipping Insurance:");
});

Upvotes: 7

Shaun Hare
Shaun Hare

Reputation: 3871

$("td:contains('Handling Fee:').text('Shipping Insurance');

Upvotes: 0

Kieran
Kieran

Reputation: 18059

I don't see any javascript there just html

you want to turn this.. <td colspan="3" style="text-align:right">Handling Fee:</td>

into this... <td colspan="3" style="text-align:right">Shipping Insurance:</td>

Upvotes: -1

Related Questions