Split string with JavaScript

后端 未结 3 1756
萌比男神i
萌比男神i 2021-01-02 17:44

how to parse this string with java script

19 51 2.108997
20 47 2.1089

like this

19 51 2.108997         


        
3条回答
  •  情话喂你
    2021-01-02 18:14

    var wrapper = $(document.body);
    
    strings = [
        "19 51 2.108997",
        "20 47 2.1089"
    ];
    
    $.each(strings, function(key, value) {
        var tmp = value.split(" ");
        $.each([
            tmp[0] + " " + tmp[1],
            tmp[2]
        ], function(key, value) {
            $("" + value + "").appendTo(wrapper);
        }); 
    });
    

提交回复
热议问题