开发者

Replace value in unordered list (html) + JQuery

D1 D2 D3

I need to change just the values between开发者_StackOverflow <span> and </span> D1, D2, D3 with JQuery, with new values like X1,X2,X3 with JQuery.


$('#nav-d1 span').text('X1') would change <span>D1</span> to <span>X1</span>


use

$('#navigation').find('span').each(function(){
    var $this = $(this);
    $this.text(function(i, curr){
         return curr.replace(/D/, 'X');
    });
});

That would fit exactly your example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜