- This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Appended image not showing
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('');
});
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 ; ????
That doesn’t work, besides it does not tell the h2 tag where to place the image which .append does. Thanks anyway.
Is jQuery library loading properly? The script you’ve provided looks correct.
“Hits head against wall” …Thanks Jamy, I completely forgot to load the jQuery library. Now it works…duh!
Haha it happens to all of us :p
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();
});