本文介绍了从outerHTML中删除完整标记并将旧标记替换为旧标记。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 您好, 我正在使用外部控件,它在对象中提供了outerHTML。然后对这个outerHTML做进一步的处理。我想在OuterHTML中做一些修改。我的OuterHTML如下。Hello,I'm using external control which gives me outerHTML in an object. then do further process on this outerHTML. I want to do some modification in OuterHTML. My OuterHTML is as follow.<div id="leftPane" class="clsPane" width="100%"> <div id="listgridview" class="gridbox gridbox_vss_listview"> <table> <tbody> <tr class=" ev_vss_listview" idd="-1"> <td align="left"> <div style="white-space: nowrap; height: 20px; overflow: hidden"> <span id="nodeval">All Products</span></div> </td> <td align="left"> </td> </tr> <tr class=" ev_vss_listview" idd="1094"> <td align="left"> <div style="white-space: nowrap; height: 20px; overflow: hidden"> <img önclick="show();" align="absMiddle" src="http://localhost/vssPLSUI/(S(l54mqqg1u502242khw54j33s))/images/plus.gif"> <span id="nodeval">afsadf</span></div> </td> <td align="left"> </td> </tr> <tr class=" ev_vss_listview" idd="79"> <td align="left"> <div style="white-space: nowrap; height: 20px; overflow: hidden"> <img önclick="show();" align="absMiddle" src="http://localhost/vssPLSUI/(S(l54mqqg1u502242khw54j33s))/images/plus.gif"> <span id="nodeval">AllProducts-Group</span></div> </td> <td align="left"> </td> </tr> <tr class=" ev_vss_listview" idd="1088"> <td align="left"> <div style="white-space: nowrap; height: 20px; overflow: hidden"> <img önclick="show();" align="absMiddle" src="http://localhost/vssPLSUI/(S(l54mqqg1u502242khw54j33s))/images/plus.gif"> <span id="nodeval">CheckUL</span></div> </td> <td align="left"> </td> </tr> <tr class=" ev_vss_listview" idd="1077"> <td align="left"> <div style="white-space: nowrap; height: 20px; overflow: hidden"> <img önclick="show();" align="absMiddle" src="http://localhost/vssPLSUI/(S(l54mqqg1u502242khw54j33s))/images/plus.gif"> <span id="nodeval">New List1</span></div> </td> <td align="left"> </td> </tr> <tr class=" ev_vss_listview" idd="929"> <td align="left"> <div style="white-space: nowrap; height: 20px; overflow: hidden"> <img önclick="show();" align="absMiddle" src="http://localhost/vssPLSUI/(S(l54mqqg1u502242khw54j33s))/images/plus.gif"> <span id="nodeval">rajiv</span></div> </td> <td align="left"> </td> </tr> <tr class=" ev_vss_listview" idd="1072"> <td align="left"> <div style="white-space: nowrap; height: 20px; overflow: hidden"> <img önclick="show();" align="absMiddle" src="http://localhost/vssPLSUI/(S(l54mqqg1u502242khw54j33s))/images/plus.gif"> <span id="nodeval">Rishu</span></div> </td> </tr> </tbody> </table> </div> </div> 我在一个变量中有这个HTML。如何删除所有< img>从此HTML中标记并获取变量中的剩余部分。所以我可以用外部HTML替换它。I have this HTML in one variable. how can I remove all <img> tag from this HTML and get the remaining part in an variable. so That I can replace it with outer HTML.推荐答案var htmlWithoutIMG = yourOuterHtml.replace(/<img[^>]+>/g, ''); b $ b [更新] 演示 - [Demo]从HTML中删除图像标签 [ ^ ]。 这篇关于从outerHTML中删除完整标记并将旧标记替换为旧标记。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-04 00:51