简体   繁体   中英

How do I remove   in IE?

I have some javascript code which removes non-breaking-space. It doesn't work in IE, however it does work in Chrome/FF/Safari.

Wonder if someone can tell me why... ?

<table id="shelf">
<tr class="row_products">
    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<!-- C5_5 --> some content...</td>
    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<!-- C5_2 --> some content...</td>
    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<!-- C5_3 --> some content...</td>
    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<!-- C5_1 --> some content...</td>
    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<!-- C5_6 --> some content...</td>
    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<!-- C5_4 --> some content...</td>
</tr>
</table>

<script type="text/javascript"> 
document.getElementById("shelf").innerHTML = document.getElementById("shelf").innerHTML.replace(/&nbsp;/g,"");
</script>

This code is directly after a table with id #shelf. I only have limited control of the output of my software, thus the non-breaking-spaces which needs to be removed (because it breaks the page design/look).

Hope everything is clear! Many thanks for any help!

尝试:

document.getElementById(\"shelf\").innerHTML = document.getElementById(\"shelf\").innerHTML.replace(/\&nbsp[ ]*\;/gi,"");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM