I need to dynamically create (based on json
) slider components (stored in li
).
Here is the code to be inserted into ul:
<li class="slider__li"> <div class="slider__block"> <div class="slider__sale slider__sale-pos">-30%</div> <div class="slider__img"><img src="/images/b1.png" alt=""></div> </div> </li>
Here is the jquery code that works with json:
$.getJSON('js/sliders.json', function (data) { for (var i = 0; i < data.slider1.length; i++) { var k = "Вот сюда нужно вставить HTML"; $('.slider__ul').append(k); }; });
But when I insert the html
code into a variable, there is a conflict with the "quotes", and the result is not a string, but what the hell, and it’s impossible to insert elements from json
.
How to solve this problem?
var k = 'HTML';
? - Alexey Shimansky