473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

example on how to change href's text needed....

Mel
can someone post a simple javascript to change the text of the <href> for me
?

thanks
Jul 23 '05 #1
5 25960
Lee
Mel said:

can someone post a simple javascript to change the text of the <href> for me
?


What is "the text of the <href>" ?
The visible text of the link, or the href attribute value?

Jul 23 '05 #2
Mel
< a href=xxx>ABCD</a>

ABCD is what i need to change :-)

thanks

"Lee" <RE**************@cox.net> wrote in message
news:d1*********@drn.newsguy.com...
Mel said:

can someone post a simple javascript to change the text of the <href> for me?


What is "the text of the <href>" ?
The visible text of the link, or the href attribute value?

Jul 23 '05 #3
Lee
Mel said:

< a href=xxx>ABCD</a>

ABCD is what i need to change :-)

thanks

"Lee" <RE**************@cox.net> wrote in message
news:d1*********@drn.newsguy.com...
Mel said:
>
>can someone post a simple javascript to change the text of the <href> forme >?


What is "the text of the <href>" ?
The visible text of the link, or the href attribute value?

<a id="Link1" href="xxx">ABCD</a>

<script type="text/javascript">
document.getElementById("Link1").innerHTML="WXYZ";
</script>

Jul 23 '05 #4
Lee wrote:
Mel said:
< a href=xxx>ABCD</a>

ABCD is what i need to change :-)

thanks

"Lee" <RE**************@cox.net> wrote in message
news:d1*********@drn.newsguy.com...
Mel said:

can someone post a simple javascript to change the text of the <href> for

[...]

<a id="Link1" href="xxx">ABCD</a>

<script type="text/javascript">
document.getElementById("Link1").innerHTML="WXYZ";
</script>


A couple of other alternatives:

Really simple:

<a id="Link1" href="#" onclick="
this.innerHTML = 'WXYZ';">ABCD</a>

With a function, passing a reference:

<a id="Link1" href="#" onclick="modText(this);">ABCD</a>

<script type="text/javascript">
function modText(ele){
ele.innerHTML="WXYZ";
}
</script>

As above, but using DOM rather than the non-standard innerHTML:

<a id="Link1" href="#" onclick="modText(this);">ABCD</a>

<script type="text/javascript">
function modText(ele){
ele.childNodes[0].nodeValue = "WXYZ";
}
</script>

--
Rob
Jul 23 '05 #5
Mel wrote:
can someone post a simple javascript to change the text of the <href> for me ?

thanks


<html>
<head>
<style type="text/css">

a {display: block; font: 500% tahoma; color: crimson;}

</style>
<script type="text/javascript">

function setLinkText(sLink_id, sText)
{
var el;
if (document.getElementById
&& (el = document.getElementById(sLink_id))
|| document.all
&& (el = document.all[sLink_id]))
{
while (el.hasChildNodes())
el.removeChild(el.lastChild);
el.appendChild(document.createTextNode(sText));
}
}

onload = function()
{
setTimeout("setLinkText('foo1', 'zippity');", 2000);
setTimeout("setLinkText('foo2', 'doo');", 3000);
setTimeout("setLinkText('foo3', 'dah !');", 3500);
}

</script>
</head>
<body>
<a id="foo1" href="#">z</a>
<a id="foo2" href="#">d</a>
<a id="foo3" href="#">d</a>
</body>
</html>

Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Peter | last post by:
Hi at all, how can I do to make a css file to change automatically the text size of the text that is into a table relatively the screen size? I.E. if the screen is 800 x I want the text...
17
by: Christopher Nelson | last post by:
I have a menu tree made up of anchors inside list items in a multi-level list that includes HTML like: <ul id='xx'> <li><a href='conf.cgi' class='menu' target='main' title='Configure stuff'...
3
by: Charlie Dison | last post by:
Hi there, How can I change the caption of a button in a grid at runtime? I seem to be able to change the header text in the column where the button appears but not the button caption. Thanks in...
2
by: Simon | last post by:
Dear reader, Is it possible to change the text of a label in a form on the event "By open". In the event some VBA code will change the label text.
3
by: ajaspersonal | last post by:
"i want to change font_style (hyper link<a href...>text</a>) normal to italics.when load a page" this is my problem but that label included in one 'USERCONTROL' This user controls may...
0
by: write2jagdeep | last post by:
i Want to change color of text item when got focus in forms builber d2k and revert that color when lost focus. Pls anser it urgently.
2
by: Rinaldo | last post by:
How to change the button text of a openfiledialog in to my own custum test?
1
by: Amit00 | last post by:
Hi, I have an ascx file with a gridview, and I need to change the header text of the gridview's column in the code-behind. Something like that: foreach (DataControlField col in GridView1.Columns)...
13
by: BobLewiston | last post by:
Can anybody tell me how to change WinForm controls' text color programatically? I have no problem finding the fields to assign colors to, but the compiler doesn't recognize any color I mention,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.