12.Append to Body (Some help please)


#1

hi
seems to me that my code is correct but it doesn't work
can anyone tell me what's wrong with it ?

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

i've got undefined as answer when i click on the add! button in the prewiew window and an error message saying that i should follow the inetruction in the preview window in the scrip sheet


#2

In your .html file what is the name of input tag checkListItem or elementCheckList ?

the name of input tag should be inside " "

var aAjouter = $('input[name="elementCheckList"]').val();

and after click on Vérifier vos réponses read the instruction below next to Revenir à l'éditeur button and do that then wait 1/2 second


#3

thanks a lot in fact in my html doc the input tag name is checkList Item
i haven't check it before that's my fault...


#4

that works fine on the prewiew wiwdow but i've still got the error message on the scrip sheet :

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


#5

can you please show me your html and jQuery updated code here?
and did you do what i said ?

after click on Vérifier vos réponses read the instruction below next to Revenir à l'éditeur button and do that then wait 1/2 second


#6

there is the html :




To Do




To Do





Add!





and the jQuery one :slight_smile:

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

' + aAjouter + '
')
});
});

thanks for helping


#7


#8

check it

now i m seeing your code

edit: please paste your code clearly


#9

just do it
In your .htm file change the name of the div id from button to bouton

and in your .js file change the same

$('#bouton').click(function(){

and do what i said

and after click on Vérifier vos réponses read the instruction below next to Revenir à l'éditeur button and do that then wait 1/2 second

hope it'll slove your problem :slight_smile:


#10

thanks it works fine even if in the preview window the add! button diseaper


#11

to make it appear again i just change the css code if this could help someone


#12

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.