mercredi 28 février 2018

Span doesn't work

How i can change code? nodeValue is a string type and it's also write in replace word!

walk(document.body);

function walk(node)  
{

    var child, next;

    switch ( node.nodeType )  
    {
        case 1: 
        case 9:  
        case 11: 
            child = node.firstChild;
            while ( child ) 
            {
                next = child.nextSibling; 
                walk(child);
                child = next;
            }
            break;

        case 3: 
            handleText(node);
            break;
    }
}

function handleText(textNode) 
{
    var v = textNode.nodeValue;

    v = v.replace(/ddd/gi, '<span class="red">N</span>');
    v = v.replace(/fff/gi, '<span class="yellow">N</span>');
    v = v.replace(/ccc/gi, '<span class="green">N</span>');

    textNode.nodeValue = v;
}




Aucun commentaire:

Enregistrer un commentaire