javascript - JQuery string, how to split and change the order -


i'm wondering there way split string in jquery , display in different order ? example: aaa bbb, ccc should bbb aaa ccc (no comma!)

<div class="string">aaa bbb, ccc</div> 

any ideas welcome

it depends on want achive , there several ways 1 way:

var text = $('.string').html().replace(',','').split(' ');  $('.string').text(text[1] + ' ' + text[0] + ' ' + text[2]); 

see live here: http://jsfiddle.net/trufa/7dg8g/


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -