Home > Software design >  split values with commas to new lines in HTML
split values with commas to new lines in HTML

Time:12-28

I have values in my HTML like so:

<div>{{countryname}}</div>
<div>{{countryactivity}}</div>
<div>{{countryactivitycount}}</div>

These values are already grouped and separated by a comma, e.g. "Country1, Country1, Country1"

The output looks like this:

Country1, Country1, Country1    
Activity1, Activity1, Activity2    
Count10, Count3, Count4

How can I get it to look like this:

| Country1 | Activity1 | Count10
| Country1 | Activity2 | Count3
| Country1 | Activity1 | Count4 

I am new to HTML but can't seem to find an answer to this.

CodePudding user response:

You could try making a Table out of it and making them columns, but the easiest approach would be to use JavaScript. For example you can make a function that could replace commas with "|".

CodePudding user response:

It is not possible with only HTML.you to need to write Javascript to convert it.

  •  Tags:  
  • html
  • Related