i wanted to use this sample code from code pen http://codepen.io/emilioincerto/pen/yaVzJd
However, when i want to use it my java script isn't working
Here is my code.
<!DOCTYPE html>
<html>
<head>
<script src="../java/java2.js"></script>
<title>
</title>
</head>
<body>
<h1>Shopping List</h1>
<ul class="shopping-list">
</ul>
<div>
<input type="text" id="item" />
<button id="b1" value="Add">Add</button>
</div>
</body>
</html>
************This is JavaScript***********
$(document).ready(
function(){
$("#b1").on("click", function(){
//grab the value of input element with id item and set it to userinput
var userInput = $("#item").val();
//log userinput to the console
console.log( userInput );
var shoppingItem = $(document.createElement("li"));
//shoppingItem.addClass("item");
shoppingItem.html(userInput);
if (userInput.length > 3){
$("ul.shopping-list").append(shoppingItem);
//clear all input fields
$("input").val("");
}
});
$("ul").on("click", "li", function(){
console.log("test number two");
$(this).remove();
});
}
);