Javascript更改最后一个子标签内容

时间:2015-01-30 21:40:02

标签: javascript jquery html forms

我在html中有这是一个BigCommerce网站,他们的支持不知道如何更改变量上的名称。唯一的事情是我们必须使用javascript函数:



<dd class="GiftCertificateThemeList" style="display: ">
    <div class="FloatLeft">
    <label>
    <div class="radio">
    <span class="checked">
    <input class="themeCheck" type="radio" value="Birthday.html" name="certificate_theme">
    </span>
    </div>
        Birthday
    </label>
    <br>
    <label>
    <div class="radio">
    <span>
    <input class="themeCheck" type="radio" value="Celebration.html" name="certificate_theme">
</span>
</div>
Celebration
</label>
<br>
<label>
<div class="radio">
<span>
<input class="themeCheck" type="radio" value="Christmas.html" name="certificate_theme">
</span>
</div>
Christmas
</label>
<br>
<label>
<div class="radio">
<span>
<input class="themeCheck" type="radio" value="General.html" name="certificate_theme">
</span>
</div>
General
</label>
<br>
<label>
<div class="radio">
<span>
<input class="themeCheck" type="radio" value="Girl.html" name="certificate_theme">
</span>
</div>
Girl
</label>
<br>
<label>
<div class="radio">Valentine</div>
Boy
</label>
<br>
</div>
<div class="clear"></div>
</dd>
&#13;
&#13;
&#13;

我需要将最后一个项目的标签文本更改为情人节。

有人可以帮我这样做吗?

我可以添加javascript没问题。

1 个答案:

答案 0 :(得分:1)

$(document).ready(function(){
    $('div.radio:last').parent().html(function(){
        var html = $(this).find('div');
        $(this).text('Valentine').prepend(html);
    }); 
});