Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace first character inside the label

How can I change each labels first character except the last labels character $ sign to £ using jQuery?

Here is the code:

<p align="center" id="myradio">
    <label>$25.00 </label>
    <input checked="checked" class="hide_input" name="amount" type="radio" value="25.00" />
    <label>$50.00</label>
    <input class="hide_input" name="amount" type="radio" value="50.00" />
    <label>$100.00</label>
    <input class="hide_input" name="amount" type="radio" value="100.00" />
    <label>$250.00</label>
    <input class="hide_input" name="amount" type="radio" value="250.00" />
    <label>$500.00</label>
    <input class="hide_input" name="amount" type="radio" value="500.00" />
    <label>$1000.00</label>
    <input class="hide_input" name="amount" type="radio" value="1000.00" />
    <label>other amount</label>
    <input class="show_input" id="other" name="amount" type="radio" value="" />
</p>
like image 315
user1235905 Avatar asked Dec 02 '22 22:12

user1235905


1 Answers

You can use the internal looping to swap the characters:

$("#myradio label").html(function(){
    return this.innerHTML.replace( '$', '£' ); 
});
like image 138
Sampson Avatar answered Dec 10 '22 11:12

Sampson