Dynamically Adding Collapsible Divs By Looping Through Array Elements With Javascript
I am trying to use JavaScript to loop through an array and append collapsible divs to a collapsible set div. I had it working and but not sure what happened. I searched stackoverfl
Solution 1:
You need to create a collapsible inside for or $.each
loops. And then append them to collapsible-set and refresh it using .collapsibleset()
.
var collapsible = '';
$.each(showPrice, function (i, v) {
collapsible += "<div data-role='collapsible'><h1>" + v.day + "</h1><p>contents</p></div>";
});
$("#classList").append(collapsible).collapsibleset();
Post a Comment for "Dynamically Adding Collapsible Divs By Looping Through Array Elements With Javascript"