0

我正在使用以下 JS 来模仿 Firfox 的省略号。一切正常,但我需要更改文本的方向,以便省略号位于文本的开头而不是结尾。

有谁知道如何将此功能添加到下面的代码中

提前致谢

大号

(function($) {




$.fn.ellipsis = function(enableUpdating){
    var s = document.documentElement.style;
    if (!('textOverflow' in s || 'OTextOverflow' in s)) {
        return this.each(function(){
            var el = $(this);
            if(el.css("overflow") == "hidden"){

                var originalText = el.html();
                var w = el.width();

                var t = $(this.cloneNode(true)).hide().css({


                    'position': 'absolute',
                    'width': 'auto',
                    'overflow': 'visible',
                    'max-width': 'inherit'
                });
                el.after(t);

                var text = originalText;
                while(text.length > 0 && t.width() > el.width()){
                    text = text.substr(0, text.length - 1);
                    t.html(text + "...");
                }
                el.html(t.html());

                t.remove();

                if(enableUpdating == true){
                    var oldW = el.width();
                    setInterval(function(){
                        if(el.width() != oldW){
                            oldW = el.width();
                            el.html(originalText);
                            el.ellipsis();
                        }
                    }, 200);
                }
            }
        });
    } else return this;
};

})(jQuery);

4

1 回答 1

0

它应该通过添加来工作

'direction': 'rtl'

到您已经使用的 CSS 映射。

于 2011-05-17T10:58:09.880 回答