Jump to content
Larry Ullman's Book Forums


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About TheFundamentals

  • Rank
  1. Hi, on page 292, Larry says that the target property 'points to the HTML element that triggered the event'. Does this mean that, in the following example, var target points to the same location as var username: function checkUsername(e) { var target = e.target; } var username = document.getElementById('name'); username.addEventListener('blur', checkUsername, false); If so, is this a general rule i.e. does the target property 'point' to the same location as document methods such as getElementById()? Thanks.
  2. ***Sorry, it's from the To-Do Manager pg 204*** Hi, I need confirmation that my interpretation of the code below is correct and concerns the information displayed to the user. tasks[]; if (task.value) { tasks.push(task.value); message = '<h2>To-Do</h2><ol>'; for (var i = 0, count = tasks.length; i < count; i++) { message += '<li>' + tasks + '</li>'; } message += '</ol>'; output.innerHTML = message; } Each time the user presses submit, a task is added to the global tasks[] array. This causes the loop to swing into action and the task is visibly outputted to the user. When a new task is added, it appears to the user underneath each previously outputted task, which despite use of the submit button, don't appear to have been refreshed. That is to say, it 'appears' that the loop is outputting only the most recent task, when logic would dictate that the loop starts again and goes right through the tasks from [0] until i < count, thus reprinting the original indexes it printed out previously (+1). Would I be correct in thinking that the fact that the previous tasks outputted to the user don't disappear and reappear owing to each iteration of the loop is because it is happening 'in the blink of an eye'? Thanks.
  • Create New...