upendra
upendra

Reputation: 2189

Ho to put a new line in <p> tag in my jquery?

I have text like this generated from flask with query

Predictions: Apple Cedar rust - 99.646: Cedar apple rust is a fungal disease caused by Gymnosporangium juniperi-virginianae that requires juniper plants to

Now I wanted to put this into 2 lines like this

Predictions: Apple Cedar rust - 99.646

Cedar apple rust is a fungal disease caused by Gymnosporangium juniperi-virginianae that requires juniper plants to

Here is my jquery code that generated above output.

var new_data = JSON.parse(data.payload);
           $('#result').append('Predictions: ');
           for (var i in new_data){
             var _html = `
               <p>${new_data[i].name}: ${new_data[i].val}</p>
             `
              $('#result').append(_html);
           }

I tried to do this but didn't work.

<p>${new_data[i].name}: "<br />" ${new_data[i].val}</p>

How do I do this?

Upvotes: 1

Views: 1205

Answers (2)

Abdul Muheet Shaikh
Abdul Muheet Shaikh

Reputation: 21

try this.

var _html = "<p>" + ${new_data[i].name}: ${new_data[i].val} + "</p>";

Upvotes: 2

Hồng Lưu
Hồng Lưu

Reputation: 29

Try this:

<p>
  <span style="display:block">${new_data[i].name}:</span> ${new_data[i].val} 
</p>

Upvotes: 1

Related Questions