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 Selecting Elements and Adding Events with JavaScript Perform: Selecting Elements

Having same problem as below where the workspace is returning undefined variables. I have not tried other workspaces.

Here is my code:

I am having the same issue. Here is my code:

//Problem: user interaction doesn't provide desired results.
//Solution: Add interactivity so the user can manager daily tasks.
var taskInput = document.getElementById("new-task"); = //new-task
var addButton = document.getElementByTagName("button") [0]; = //first button
var incompleteTaskholder = document.getElementById("incomplete-tasks"); //incomplete-tasks
var completedTaskholder  = document.getElementById("completed-tasks"); //completed-tasks

//Add a new task
var addTask = function() {
  //When button is pressed, 
  //Create a new list item with the text from #new-task
    //input (checkbox)
    //Label
    //input (text)
    //button.edit
    //button.delete
    //each element needs to be modified and appended
}

//Edit an existing task
var editTask = function() {
  //If the parent has the class .editMode
    //switch from .editMode
    //Make lable text become input value
  //else
    //Switch to .editMode
    //input value becomes the label's text

  //Toggle .editMode
}

//Delete an existing task
var deleteTask = function() {
    //When delete button is pressed
    //Remove parent list item from the ul
}

//Mark a task as complete
var taskCompleted = function() {
    //When the checkbox is checked
      //Append the task list item to the #completed-tasks
}

//Mark a task as incomplete
var taskIncomplete = function() {
    //When the checkbox is unchecked
      //Append the task list item to the #incompleted-tasks

3 Answers

Stephen Bone
Stephen Bone
12,359 Points

Hi Anna

I've found a few initial problems (with the code you've posted anyway).

On lines 3 and 4 after the semi-colon there are unnecessary equals signs, these can just be deleted.

Your taskIncomplete function has no closing curly brace (possibly just missed it out when you've pasted it in here).

And lastly on line 4 the method is getElementsByTagName (note the "s" on Elements is missing on your code).

So it should be as below:

var addButton = document.getElementsByTagName("button")[0];//first button

Hope it helps!

Thanks, Stephen. I still can't get the console to work in Workspace but now I know it's not because of my code.

I was having this same problem and it was driving me crazy!

The following worked for me after checking that there were no errors with my code:

I saved my workspace and refreshed the preview of my To Do list. Then I re-opened the JavaScript console and it worked just fine.

By not refreshing the preview, it wasn't applying the new code from the Workspace.