如何使用jquery删除noscript标签包装器?

我想删除环绕图像的noscript标记:

     

我试过unwrap() ,但它在noscript中不起作用,接下来我尝试了html()方法:

 $('a').html(function(index, oldhtml){ return oldhtml.replace(/\/g, ''); }); 

虽然删除了标记,但它会生成一个字符串而不是DOM:

  "  "  

如何在保持img元素不变的同时删除noscript标记包装?

尝试类似的事情 – 事实上这是一个非常粗暴的黑客行为

 jQuery(function($){ $('a:has(noscript)').html(function(){ return $(this).find('noscript').text() }) }) 

演示: 小提琴

你可以用它的内容替换元素:

 $('noscript').replaceWith(function() { return this.textContent || this.innerText; // return $('
').html(this.innerHTML).text(); });

http://jsfiddle.net/x9Eaw/

你可以这样试试:

 var image=$('noscript').text(); $("noscript").remove(); $("a").append(image); 

演示小提琴

为什么不保留noscript并自己添加图像?

 $("noscript").each(function () { $('').appendTo(this.parentNode); }); 

小提琴

    noscript can change the Internet forever