Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Interactive Web Pages with JavaScript Traversing and Manipulating the DOM with JavaScript Perfect

John Girard
John Girard
6,349 Points

adds a blank item with edit/delete buttons but no text after typing in the add item box.

snapshot of workspace: https://w.trhou.se/ullwxrvvbo

won't work in chrome or firefox

1 Answer

Kris Phelps
Kris Phelps
7,609 Points

I see in your code where you pass the value of the taskInput element to your createNewTaskElement function:

var listItem = createNewTaskElement(taskInput.value);

But I don't see where taskString is referenced in that function:

//New Task List Item
var createNewTaskElement = function(taskString) {
  //Create List Item
  var listItem = document.createElement("li");

//input checkbox
  var checkBox = document.createElement("input"); //checkbox

  //label
  var label = document.createElement("label");

  //input (text)
  var editInput = document.createElement("input"); //text

  //button.edit
  var editButton = document.createElement("button");

  //button.deletes
  var deleteButton = document.createElement("button");

  //Each elements needs modifying
  checkBox.type = "checkbox";
  editInput.type = "text";

  editButton.textContent = "Edit";
  editButton.className = "edit";
  deleteButton.textContent = "Delete";
  deleteButton.className = "delete";


  //Each element needs appending
  listItem.appendChild(checkBox);
  listItem.appendChild(label);
  listItem.appendChild(editInput);
  listItem.appendChild(editButton);
  listItem.appendChild(deleteButton);


  return listItem;
}

I hope this helps :-)