vendredi 1 mars 2019

Add new line using jQuery concat

Through ajax response I'm passing array data from controller to blade.

enter image description here

On Ajax success I'm looping through array with 2 elements and concatenating string to display later on in my bootstrap popover.

success: function (data) {
                var content = "";
                var num = 1;
                for (var i = 0; i < data.length; i++) {
                    content = content.concat(num + "." + " " + data[i]);
                    num++;
                }
                $("#content").popover({content: content});
            }

Result:

enter image description here

I would like to add new line, so that each item or "artikel" would be displayed in new line e.g. :

1.Artikel...
2.Artikel...

I tried to add "\n" (as below) or html break but nothing works, it only appends as string.

content = content.concat(num + "." + " " + data[i] + "\n");



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire