There is a code:

var ul = document.getElementById('products'), docfrag = document.createDocumentFragment(), products = [ { name: "test1", price: 240 }, { name: "test2", price: 250 }, { name: "test3", price: 260 }, { name: "test4", price: 270 }, { name: "test5", price: 280 }, { name: "test6", price: 290 } ]; products.forEach(function(e) { var div = document.createElement("div"); div.textContent = '<br>' + e.name + ' ' +e.price; docfrag.appendChild(div); }); ul.appendChild(docfrag); products.forEach(function(e) { if(e.price == 250) alert(e.name); return; }); <div id="products"> </div> 

How to make so that those would be output not as text, but transfer the string?

    1 answer 1

    you write the data in a div as text, and you need to use innerHTML

     div.innerHTML = '<br>' + e.name + ' ' +e.price; 
    • And for sure, thanks) - arthru
    • yes there is nothing :) - splash58
    • @ splash58 Mark the answer as correct if it suits you - Vasily Barbashev
    • @ Vasily Barbashev I don’t even know what to answer :) I tried, it does not work :))) - splash58
    • @ splash58 ugh, you didn’t write to that: D - Vasily Barbashev