Replace value in unordered list (html) + JQuery
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.
精彩评论