gpt4 book ai didi

javascript - 替换标签内的第一个字符

转载 作者:搜寻专家 更新时间:2023-11-01 04:46:07 25 4
gpt4 key购买 nike

如何使用 jQuery 将每个标签的第一个字符(最后一个标签字符 $ 符号除外)更改为 £?

代码如下:

<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>

最佳答案

您可以使用内部循环来交换字符:

$("#myradio label").html(function(){
return this.innerHTML.replace( '$', '£' );
});

关于javascript - 替换标签内的第一个字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10337586/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com