I want to add array element in class selector, I have attached image the result is , I want div separated like this
$(document).ready(function () {
var arr = ['top', 'right', "Bottom", "left"]
var direction = "";
$.each(arr, function (index, value) {
direction += value
});
$("#directionSec").html("<div class='directionMain'><span class='directionHeader'><h5>Header</h5>" + "<div id='result' class=" + direction + ">" + direction + "</div>" + "</span>");
})
The result I am getting
<div class="toprightbottomleft"> toprightBottomleft</div>
The result I wanted
<div class="top">top</div>
<div class="bottom"> bottom</div>
"top right Bottom left"with spaces between the values?