Bonsai jQuery Project 1 Trouble


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/en/courses/jquery-ext/projects/jquery-prj_bonsai

<In what way does your code behave incorrectly? Include ALL error messages.>
I am having trouble making it so the text I type in the fields updates the meme. Here is what my code looks like for one of the parts:

('#top-text').keyup(function(){ (this).val(function(){
$(’.top-caption’).text(this);
});
});

So what it is supposed to do is update the top-caption div of the meme with the text that the user types in the top-text input. However, when I run the code like this, every time I try to type text into the input box, it instantly disappears and the meme does not update. I know that my code is wrong somewhere because I am pretty sure that I am not using ‘this’ properly.

Any help would be much appreciated. Thanks.

```

('#top-text').keyup(function(){ (this).val(function(){
$(’.top-caption’).text(this);
});
});

<do not remove the three backticks above>

#2

This post was flagged by the community and is temporarily hidden.


#3

Hi. Thanks for answering. Unfortunately, changing my 2 lines of code to your 1 line still did not resolve the issue: The text still does not show up on top of the picture.

var main = function() {
('#top-text').keyup(function(){ (’.top-caption’).text(this.val);
});

('#bottom-text').keyup(function(){ (’.bottom-caption’).text(this.val);
});

('#image-url').keyup(function(){ (’#image-url’).attr(‘src’,this.val);
});
};

$(document).ready(main);


#4

This post was flagged by the community and is temporarily hidden.


#5

Thank you for your help.