Jump to content

PLZ Help! i don't know why its not working


Recommended Posts

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>

<script src="../java/java2.js"></script>

<h1>Shopping List</h1>
<ul class="shopping-list">

  <input type="text" id="item" />
  <button id="b1" value="Add">Add</button>

************This is JavaScript***********

    $("#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"));
      if (userInput.length > 3){
        //clear all input fields
   $("ul").on("click", "li", function(){
      console.log("test number two");  
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...