2011-04-13 58 views
0

有一个可折叠的嵌套脚本HereJavascript替换文字

在代码中,如果我有<ul>Name它会将其转换为<ul><a href="#">&plusmn; Name</a>

不过,如果我已经有喜欢的链接:

<ul> <a href="#"Name</a>将其转换为

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

我想将它们合并为:<ul><a href="#">&plusmn; Name</a>。我不确定如何做到这一点。

我知道它是做

 //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); 

回答

0

你想放置一个链接到UL节点withot打开一个LI的东西吗? 您的浏览器将自动关闭UL