Guntars Viciuss Guntars Viciuss - 5 months ago 22
Javascript Question

Javascript for in send as setAttribute

Hello at school my teacher changed my code to example down below
and it's not working and i can't understand how it works and fix it
sorry don't know how to ask this question correctly!!!

can some one help me whit it..?

function _$(e, attrs) {
var el = document.createElement(e);
for(a in attrs){
el.setAttribute(a, attrs[a]);

var $taskMain = _$("section", { "class": "sdfjsf", "id": "taskId", "data-id-number": "sajfsaf"});

//and i have error
//template.js:80 Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.


I think you're missing a return el; at the end of your _$ function.