javascript - Place an image next to each dynamic div created -
i creating function dynamic div. function working, want contain 1 same image in front of each innerhtml name. how possible? in advance
function createdivbusiness(returned_data){ var output = document.getelementbyid("business"); (var i=0; i<returned_data.name.length; i++){ var element = document.createelement("div"); element.setattribute("id",'business'+i); element.setattribute("tabindex","0"); element.setattribute("class","styled-business"); element.innerhtml=returned_data.name[i]; output.appendchild(element); } }
you this
element.innerhtml= "<img src='path_to_image' alt='some text'>" + returned_data.name[i];
Comments
Post a Comment