On 18/09/06, Christof Donat <[EMAIL PROTECTED]> wrote:
> Hi,
>
> > A regular expression is probably the best thing to use. This is nearly
> > working (but not quite)
>
> Why not using DOM? It works perfectly. Just have a look at my code. Actually I
> think, that it should be rather straight-forward to transform my code to use
> jQuery.
>
> > The reason I think it doesn't work is that there is a open tag without
> > its matching closing tag.
>
> Exactly that is no problem with DOM.
>
> Christof

It was just a suggestion on how the code could be improved (and a good
chance to work on my RegExp skills). Plus it involves a lot less code.
I would have thought performance may be a bit better (but probably not
that noticeable) due to using innerHTML rather than DOM manipulation.

This works a bit better than before (before it would not handle
whitespace at the end)

typeone = function(self, delay, text, content) {
  var next;
  if (text.length > 0) {
    next = text.match(/(\s*?(<[^>]*>)?\s*?(&[^&]*;|[^<\s])|\s)/)[0];
    text = text.substr(next.length);
    content = content+next;
    if($.trim(next) != $.trim(text)) {
      $(self)
      .html(content+'<span style="visibility:hidden">'+text+'<'+'/span>');
      setTimeout(function(){
        typeone(self, delay, text, content);
      }, delay);
    }
  }
}

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to