Having an issue learning JavaScript in a college course. This is my last project and the problem I am having with the HTML code is creating an input field for a label without an id, it has a "for" element though. It cannot be created with JQuery or JSON.
So the HTML looks something like this: <"label for="car">What car do you have? <"span class="required"><"/span><"/label">
So I was thinking I could create the input text field and add it to the DOM:
// Create the input field
var firstCar = document.createElement("input");
// Create the type node and store what the field will be text
var newType = document.createTypeNode("text");
// Create a new ID of car and attach it to the input
var newID = document.createIdNode("car")
/* put the created Element within the HTML with ["this determines which label it will be under"]:*/
var position = document.getElementByTagName("label")[1];
// Insert the element into the position
position.appendChild(firstCar);
I ran this and it says that TypeNode is not a function in my browser.
inputelement does not specify thetypeattribute, it defaults to<input type='text'>.