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
Post a Comment