I need to change only the values between <span> and </span> D1, D2, D3 using jQuery, with new values like X1, X2, X3 with jQuery.
<span>
</span>
using
$('#navigation').find('span').each(function(){ var $this = $(this); $this.text(function(i, curr){ return curr.replace(/D/, 'X'); }); });
This will fit your example.
$('#nav-d1 span').text('X1') will change <span>D1</span> to <span>X1</span>
$('#nav-d1 span').text('X1')
<span>D1</span>
<span>X1</span>