0
我有以下的HTML原型删除HTML?
<div id="top-right">
<span id="top-right-name">sometexthere</span> | <a href="#">link</a>
</div>
而下面的原型JS
Event.observe(window, 'load', function() {
try {
if ($$('#top-right')!=null) {
var topmenu = document.getElementById('top-right');
var value = topmenu.innerHTML;
// define an array of replacements
var replacements = [
{ from: '|', to: ' ' },
{ from: '|', to: ' ' },
{ from: '|', to: ' ' },
{ from: '|', to: ' ' }
];
for (var i = 0, replacement; i < replacements.length, replacement = replacements[i]; i++) {
// replace
value = value.replace(replacement.from, replacement.to);
}
// replace the old text with the new
topmenu.innerHTML = value;
}
}
catch(ex) {
}
});
我想删除 “|” 的</SPAN后>自动的onload的这个JS - 但我只是似乎无法做到这一点。
有人可以协助吗?
谢谢
喜肯尼 - 感谢您的帮助,但我使用Prototype库 - 不是jQuery的 - 因此语法$$: ) – Tom 2010-08-09 17:39:28
哦,废话。对不起,我没有注意到! 是至少被调用的Event.observe(window,'load',function(){})?除此之外,你的语法对我来说似乎很好! :) – 2010-08-09 17:48:58
干杯thx - 是加载问题:) – Tom 2010-08-09 18:09:32