开发者

jQuery or Javascript Solution Remove Specific Tag but leave the rest

I have a div structure that looks like this...

<div class="gallery_lightview">
<div id="lg_image">
<a href="http://www.website.com/?iframe=true&width=100%&height=100%" rel="prettyPhoto[iframes]" class="lightview_main" title="TITLE HERE">
<img class="alignnone" src="HEADER.jpg" alt="" />
</a>
</div>
</div>

What I want to do is remove the <a> tags that show up ONLY between div class "gallery_lightview" and leave the <img> tag. So once its all stripped out it would look like...

<div class="gallery_lightview">
<div id="lg_image">
<img clas开发者_C百科s="alignnone" src="HEADER.jpg" alt="" />
</div>
</div>

Basically making this a non clickable image. Is this possible?


$('.gallery_lightview').find('img').unwrap();

Find the element with class gallery_lightview, find all of its children elements (no matter how deeply nested) that are 'img' elements, then remove each of their immediate parent elements (in this case 'a' tags).


$('img').insertAfter('a'); Get and insert the element 'a' after 'img'

$('a').remove(); Remove the element 'a'


Sorry, just thought about it a little more. It's actually going on a mobile site. So...I choose not to use jQuery (cut down on the load and because I won't need most of the jQuery functionality).

Anyway this can be done in a self contained Javascript, no in the <head>?

I was thinking it would sit right before the Wordpress "the_content" call, since this is where the div is in. Any help?

Sorry for the confusion.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜