I am trying to wrap a image with a link but I am having trouble doing so.
$j('<img />', {
'src': 'imageSrc.jpg',
'style': 'display:none;',
'id': 'image'
})
.appendTo('#imageWrapper');
I have tried using .after, .before, and .wrap but the links are not coming up or they are not wrapping around the image.
I have looked at Hanpan’s problem and solution but the solution doesn’t fit mine.
Should I change my code to fit like his or am I missing something?
You can wrap an element with
wrap().Here is a jsFiddle which may be of assistance too.