Treehouse: Grow your CSS skills. Land your dream job.

Appended image not showing

  • # January 16, 2012 at 5:26 pm

    Hi Guys,
    I am having a problem with an image appended to an h2 tag not showing.
    All the paths are correct as the image and the js both show up in my browser but they are not connecting to the tag in the site.

    I have the following in a file called h2logo.js in a folder called js:

    $(function() {

    .append('phatburn logo');


    In the head section I have put

    And of course the h2 tag is on the home page of a WordPress site.

    Is there something I’m missing, like a . or a ; ????

    # January 16, 2012 at 10:43 pm

    Instead of using .append(), better use .html():

    $(function() {

    $("h2").html('phatburn logo');

    # January 17, 2012 at 12:44 am

    That doesn’t work, besides it does not tell the h2 tag where to place the image which .append does. Thanks anyway.

    # January 17, 2012 at 12:45 am

    Is jQuery library loading properly? The script you’ve provided looks correct.

    # January 17, 2012 at 1:07 am

    “Hits head against wall” …Thanks Jamy, I completely forgot to load the jQuery library. Now it works…duh!

    # January 17, 2012 at 1:09 am

    Haha it happens to all of us :p

    # January 19, 2012 at 10:20 pm

    Recap on this because I am new to WordPress and it might help someone else. The jQuery library is already loaded but WP does not accept the jQuery $ code. So to use that it means enqueuing the js or else to modify the code to jQuery instead of $

    jQuery().ready(function() {
Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.