appending one object to another in javascript -
i have created 2 objects shown in below script. i'm able append them onto page using 'document.body'. now, wanted append 'appitem' header in 'mainwrapper'. how can this.
function mainwrapper() { var wrapper; var header; function create() { wrapper = document.createelement('div'); header = document.createelement('div'); wrapper.appendchild(header); } function style() { wrapper.classname = "wrapper"; header.classname = "header"; } function init() { create(); style(); } init(); this.render = function (k) { k.appendchild(wrapper); } } function appitem() { var appitemicon; appitemicon = document.createelement('img'); appitemicon.src = 'icons/list.png'; this.appitemrender = function (k) { k.appendchild(appitemicon); } } window.addeventlistener('load', onload); function onload() { var main = new mainwrapper(); var applist = new appitem(); main.render(document.body); applist.appitemrender(document.body); }
Comments
Post a Comment