Hey guys,
Do any of you guys have a universal way to change the text between the "<a>" link tags?
Change the text between the <a> tag
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Untested
Code: Select all
<a href="foo.php" id="foo">Default text</a>
<script type="text/javascript">
<!--
if (document.getElementById('foo')) document.getElementById('foo').innerText = 'New text';
//or (can't quite remember)
document.getElementById('foo').text = 'New text';
// -->
</script>Code: Select all
function writit(text,id) {
if (document.getElementById) {
x = document.getElementById(id);
x.innerHTML = '';
x.innerHTML = text;
} else if (document.all) {
x = document.all[id];
x.innerHTML = text;
} else if (document.layers) {
x = document.layers[id];
text2 = '<P CLASS="testclass">' + text + '</P>';
x.document.open();
x.document.write(text2);
x.document.close();
}
}