Replace value in unordered list (html) + jQuery

D1 D2 D3

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.

+3
source share
2 answers

using

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

This will fit your example.

+2
source

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

+3
source

All Articles