Reverse order words in a dynamic sentence

后端 未结 2 1278
温柔的废话
温柔的废话 2021-01-29 03:40

I have several tags like this:

1 Comment

I would like to do this reversing the order of the

相关标签:
2条回答
  • 2021-01-29 04:18

    You almost had it, except you're not doing anything with the result

    $('.classCover').each(function(){
        $(this).text($(this).text().split(' ').reverse().join(' '));
    });
    
    0 讨论(0)
  • 2021-01-29 04:44

    try this.

    $('.classCover').each(function(){
    
        var link = $(this).text().split(' ');
        $(this).text(link[1] + "(" + link[0] + ")");
    });
    
    0 讨论(0)
提交回复
热议问题