Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6558273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:10:45+00:00 2026-05-25T13:10:45+00:00

Links to live examples @ jsfiddle & jsbin . So this function: function symbolize(e){

  • 0

Links to live examples @ jsfiddle & jsbin.

So this function:

function symbolize(e){
    var elements = e.childNodes; // text nodes are necessary!
    console.log(elements);
    for(var i=0; i < elements.length; i++){
        t = elements[i];
        var range = document.createRange(), offset = 0, length = t.nodeValue.length;
        while(offset < length){
            range.setStart(t, offset); range.setEnd(t, offset + 1);
            range.surroundContents(document.createElement('symbol'));
            offset++;
        }
    }
}

..should iterate over every letter and wrap it in a <symbol/> element. But it doesn’t seem to be working.

So I added the console.log(); right after the *.childNodes have been fetched, but as you’ll see in the example site above, the log contains 2 unexpected elements in front(!) of the array. And yeah, because of this, I have a feeling that surroundContents(); make the changes live(!). couldn’t find any reference on this though

One of the elements is an empty Text node, the other is my <symbol/>. But yeah, this is totally unexpected result and messes up the rest of the function.

What could be wrong with it?

Thanks in advance!

Update

Oh, looks like the elements are added on Chrome, Firefox doesn’t add the elements, but still halts the function.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:10:46+00:00Added an answer on May 25, 2026 at 1:10 pm

    Element.childNodes is indeed a live list , it could not be otherwise (that would mean an incorrect list of nodes). The easiest solution is to freeze (make a copy of) it before you mess with it (by surrounding existing ranges).

    var elements = Array.prototype.slice.call(e.childNodes, 0);
    

    https://developer.mozilla.org/en/childNodes it’s of type NodeList
    https://developer.mozilla.org/En/DOM/NodeList those are live lists

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following bit of code, simply: $(function() { $('a.add-photos-link').live('click', function(e) { $(this).colorbox({
Should links on a web page ALWAYS be underlined? I do not believe this
I'm checking in Firefox 3.6 Why 2nd level links are not clickable in this
My JavaScript is as follows: $.get(/<page>.php, userid='.$userid.'&+status, function(data){ $(#status).show(fast).html(data).delay(4000).hide(fast); }); I have many links
I'm using preg_replace_callback to find and replace textual links with live links: http://www.example.com to
I have links with this structure: http://www.example.com/tags/ blah http://www.example.com/tags/ blubb http://www.example.com/tags/ blah / blubb
i have a fairly simple dropdown I build. Here is the live example: http://jsfiddle.net/K8VtB/
Just about everyone has ran into this specific issue: function addLinks () { for
Links to point me in the correct direction, or sample code will be appreciated.
Any links/Turorials avalable? I want to write a simple ISAPI plugin for IIS6.0. Prefered

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.