11/14


#1

I can't click Add button. It is normal? The course permits me to go on, but the button don't work and the compiler give me this error: SyntaxError: missing ; before statement.
There's my code:
$(document).ready(){
$('#button').click(function(){
var toAdd= $('input[name=checkLisItem]').val();
});
};
Can anyone help me?
PS: Sorry for bad English


#2

Use

$(document).ready(function(){
    $('#button').click(function(){
      var toAdd =$('input[name=checkListItem]').val();
      $('<p>').text(toAdd).appendTo('.list');
    });

 });

Try entering something and then click ADD button


#3

but thats not how Codecademy wants us to solve it, isn't it?


#4

that looks correct to me. Nothing will happen when you click the button until you complete 12/14.
If you are looking for something to happen when you hover over the div "Add", write some JQuery to make it happen.


#5

Thank you, leonhard, that helped a lot. It showed me that I didn't put parenthesis around #button.


#6

@pyrunner46174,
Have a go at
http://www.w3schools.com/jquery/trysel.asp


#7

$(document).ready(function(){
$('#button').click(function(){
var toAdd = .getElementById('checkListItem')
}
};

would be a much simpler code.


#8

And that code worked fine.


#9

@alexhepworth720 By “works fine”, do you mean it passed, or it worked? Because, it neither of those should happen (it doesn't work, & so shouldn't be passed).


#10

Hey,

just change the input's name like this:

$(document).ready(function() {
    $('#button').click(function() {

   /* What we are supposed to do
    var aAjouter = $('input[name=checkListItem]').val();
   */

   //What they are waiting from us
    $('#button').click(function() {
    var aAjouter = $('input[name=elementCheckList]').val();    
        
    });
});

As you can see in the HTML of the level, the input's name value is "CheckListItem", whereas in the solution, this is not CheckListItem but "elementCheckList"

Peace :slight_smile:


#11

Hello, I've done it :

$(document).ready(function(){
$("#button").click(function(){
var aAjouter = $('input[name=checkListItem]').val();
$('.list').append(div class='item' + aAjouter + /div);
});
});

with " and <> used for div

this code is french's version, but after I've the message :

Oups, merci de réessayer. Please follow the instructions on the Full Preview page to test your code.

I do all windows, it doesn't work so I arrive at 92% :disappointed:

Thanks for your help