开发者

Javascript replacing text

There's a Collapsible Nested Script Here.

In the code if I have <ul>Name it will convert it to <ul><a href="#">&plusmn; Name</a>.

However, if I already have a link like:

<ul> <a href="#"Name</a> it will convert it to

<ul><a href="#">&plusmn; </a>
    <a href="#">Name</a>

I want to combine them to be: <ul><a href="#">&plusmn; Name</a>. I'm unsure how to do t开发者_JS百科hat.

I know it has to do something with

        //create a link for expanding/collapsing
        var newLink = document.createElement('A');
        newLink.setAttribute( 'href', '#' );
        newLink.onclick = new Function( 'clickSmack(this,' + oLev + ',\'' + oBsID + '\',' + oCol + ',\'' + escape(oT) + '\');return false;' );
        //wrap everything upto the child U/OL in the link
        if( oML ) { var theHTML = ''; } else {
            var theT = y[x].innerHTML.toUpperCase().indexOf('<'+oT);
            var theA = y[x].innerHTML.toUpperCase().indexOf('<A');
            var theHTML = y[x].innerHTML.substr(0, ( theA + 1 && theA < theT ) ? theA : theT );
            while( !y[x].childNodes[0].tagName || ( y[x].childNodes[0].tagName.toUpperCase() != oT && y[x].childNodes[0].tagName.toUpperCase() != 'A' ) ) {
                y[x].removeChild( y[x].childNodes[0] ); }
        }
        y[x].insertBefore(newLink,y[x].childNodes[0]);
        y[x].childNodes[0].innerHTML = oPM + theHTML.replace(/^\s*|\s*$/g,'');
        theNextUL.MWJuniqueID = oIcount++;
        compactChildren( theNextUL, oLev + 1, oBsID, oCol, oPM, oT, oML );


you are trying to place a link into UL node withot opening an LI ? your browser will auto close the UL

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜