0

I'm trying to append the jquery variable into a div. When i click on the button with id #g noting shows up in my div.

$(document).ready(function() {
    $("#g").click(function() {
        var n = $('#g').val();
        $('#sentence')append('n');
    });
});
2
  • Can you show your HTML also please? There's no way for us to know if you've even se a value on #g or if you're trying to get the html, etc. Commented May 31, 2013 at 19:46
  • Did you mean to write .append? Commented May 31, 2013 at 19:48

3 Answers 3

4

Close

$('#sentence').append(n);

Remove those quotes around the variable. Also, you're missing a . between the selector and append

Sign up to request clarification or add additional context in comments.

Comments

0

You may have a typo. Try this:

$('#sentence').append(n);

Comments

0

remove those '' around n (and you forgot . before append)

$("#g").click(function() {
    var n = $('#g').val();
    $('#sentence').append(n);
});

1 Comment

Don't forget the . before append

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.