0
有一個可摺疊的嵌套腳本Here。Javascript替換文字
在代碼中,如果我有<ul>Name
它會將其轉換爲<ul><a href="#">± Name</a>
。
不過,如果我已經有喜歡的鏈接:
<ul> <a href="#"Name</a>
將其轉換爲
<ul><a href="#">± </a>
<a href="#">Name</a>
我想將它們合併爲:<ul><a href="#">± 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);