Here I am creating inside my ul ("list") a new li and a new a at the end. I'm in the process of learning javascript and am happy like a small child couse I just fixed it :)
//creates new li and new a var newSocial = document.createElement("li"); var newSocialLink = document.createElement("a"); // ads property to the href attribute newSocialLink.href = "https://twitter.com/darko_atanasov"; // creates text in the li var liText = document.createTextNode("linkedIn"); // ads text to a newSocialLink.appendChild(liText); // ads newSocial and newSocialLink to the DOM document.getElementById("list").appendChild(newSocial); document.getElementById("list").lastChild.appendChild(newSocialLink);
Comment
Here I am creating inside my ul ("list") a new li and a new a at the end. I'm in the process of learning javascript and am happy like a small child couse I just fixed it :)
//creates new li and new a
var newSocial = document.createElement("li");
var newSocialLink = document.createElement("a");
// ads property to the href attribute
newSocialLink.href = "https://twitter.com/darko_atanasov";
// creates text in the li
var liText = document.createTextNode("linkedIn");
// ads text to a
newSocialLink.appendChild(liText);
// ads newSocial and newSocialLink to the DOM
document.getElementById("list").appendChild(newSocial);
document.getElementById("list").lastChild.appendChild(newSocialLink);