JS: Dynamic List Assignment - ERR_FILE_NOT_FOUND

Hey guys

I did the assignment just like Ivan but when I press the button SUBMIT the fruit that I added appears in the list for a split second and then the web page is crushing and im geting the following message:

File not found
It may have been moved or deleted.
ERR_FILE_NOT_FOUND

can somone please help me with this

<!DOCTYPE html>
<!-- saved from url=(0127)file:///Users/_Alz/Desktop/Matteo%20Backup%20Alessio's%20Laptop/Assignement%20(Dynamic%20Lists%20and%20User%20Input%20box).html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
	<title>My First Working Page</title>
	<script src="./My First Working Page_files/jquery.min.js"></script>

</head>
<body>

<h1>This is the guestlist for tonight:</h1>

<ul id="guestnames"><li id="myself">myself</li></ul>

<input type="text" id="newguests">
<button onclick="addItem()">Add Item</button>
<button onclick="removeItem()">Remove Item</button>

<script>

var guestNames = [];

var guests = $("#guestnames");

$.each(guestNames, function(index,value) {
  $("<li/>").text(value).appendTo(guests)
});

function addItem(){
	var ul = document.getElementById("guestnames");
    var newguests = document.getElementById("newguests");
    var li = document.createElement("li");
    li.setAttribute('id', newguests.value);
    li.appendChild(document.createTextNode(newguests.value));
    ul.appendChild(li);
};

function removeItem(){
	var ul = document.getElementById("guestnames");
  var newguests = document.getElementById("newguests");
  var item = document.getElementById(newguests.value);
  ul.removeChild(item);
};


	
</script>




&gt;</body></html>
1 Like

This is how I solved it, it’s different compared to how Ivan sorts it but it works like a charm

1 Like