Bonsai project image isn't changing after all! help pls!


#1

<PLEASE USE THIS 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?link_content_target=interstitial_project
<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>

Hi:) my code works well for my top and bottom caption but the image though isn’t changing after all…can pls someone help! Thanks…

```

var main = function() {
('#top-text').keyup(function() { var top = (this).val();
('.top-caption').text(top); }); (’#bottom-text’).keyup(function() {
var bottom = (this).val(); (’.bottom-caption’).text(bottom);
});
('#image-url').keyup(function() { var img = (this).val();
$(’.meme’).attr(‘src’, img);
});
};

$(document).ready(main);

<do not remove the three backticks above>

#2

Hi,

if you look in the html code you might recognize that the image you want to switch out doesn’t have a class named ‘meme’. You could just put ‘img’ instead of ‘meme’, but this would change the picture in the header too. So if you want to adress only this particular image you have to write ‘.main img’. This selects only the image in the div with the class ‘main’.

Here the code:

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

Happy coding.


#3

thanks a lot! but i did add a class in the img but didn’t work too, thanks for your help!


#4

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