IE9 table has random rows which are offset at random columns

前端 未结 5 699
栀梦
栀梦 2020-12-04 18:27

I have a page of categories, when the user clicks one, the items under that category are loaded via a jQuery Ajax call, in a table, and stuck into an element just below the

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-04 18:58

    I used an answer from another post Remove whitespace and line breaks between HTML elements using jQuery where there was a script which was more effective than the one above. I used the answer to solve it, but I will repeat it for a complete answer.

    jQuery.fn.htmlClean = function() {
        this.contents().filter(function() {
            if (this.nodeType != 3) {
                $(this).htmlClean();
                return false;
            }
            else {
                return !/\S/.test(this.nodeValue);
            }
        }).remove();
        return this;
    }
    

    Ultimately, this is only an interim solution and should be fixed in IE9/10 by Microsoft.

提交回复
热议问题