Reputation: 174
I'm trying to add additional html after each image on the page. But, for some reason, it doesn't accept the 'img' tag. If I put 'p' tag, it works, but not for images.
$("img").append("Some text");
Any idea why this is or what am I doing wrong?
Upvotes: 0
Views: 70
Reputation: 1377
Use after('Some text')
instead of append('Some text')
.
append()
method puts the content inside the specified element whereas after()
puts the content after the specified element.
Upvotes: 2
Reputation: 15112
Use .after()
instead
$("img").after("Some text");
.append()
puts your string within the img
tag but .after()
puts it after the img
tag
Upvotes: 5