Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Appended image not showing

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #36156
    virtual
    Participant

    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() {

    $("h2")
    .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 ; ????

    #94791
    virtual
    Participant

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

    #94792
    jamygolden
    Member

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

    #94795
    virtual
    Participant

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

    #94797
    jamygolden
    Member

    Haha it happens to all of us :p

    #95034
    virtual
    Participant

    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 $
    e.g.

    jQuery().ready(function() {
    jQuery("#mydiv").show();
    });
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.