使用油脂猴子从td类中删除空格 [英] Remove blankspace from td class with greasemonkey

查看:81
本文介绍了使用油脂猴子从td类中删除空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的网页上有很多<td class="house">111 22</td>.数字是随机的,但类名是相同的,并且数字之间的空格在所有数字中都位于同一位置,我想在页面加载后删除所有这些空间.该脚本应如何工作?

If I have webpage with for example alot of <td class="house">111 22</td>. The numbers are random but classname is the same and the blankspace between the numbers are at same position in all of them, and I want to remove the space in all of them after page is loaded. How should the script look like to work?

推荐答案

    use the following code:

   <script type="text/javascript">

    window.onload = removeSpace;

    function removeSpace() {
        var emt = document.getElementById("mytable");//mytable is the Id of the table
        d = emt.getElementsByTagName("tr")[0],
         r = d.getElementsByTagName("td");
        for (var i = 0; i < r.length; i++) {
            var str = r[i].innerText;
            r[i].innerText = str.replace(" ", "");
        }
    }

</script>

这篇关于使用油脂猴子从td类中删除空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆