Re: onClick event problem
- From: Peter Michaux <petermichaux@xxxxxxxxx>
- Date: 29 Apr 2007 12:20:10 -0700
On Apr 29, 12:04 pm, getsanjay.sha...@xxxxxxxxx wrote:
Hello all, I have been trying to implement a script using which when
the user clicks on one of the two span tags, its text is highlighted
while the same happens when the user clicks on the second one, except
that the first one loses its highlight. I am at a loss as to why this
code doesn't work.
<html>
<head>
<script language="javascript" type="text/javascript">
The language attribute is deprecated and there is no need to use it.
<!--
This script hiding technique should be "// <!--" but hasn't been need
for many many years. No need to use it.
function changeOne(s)
{
document.getElementById(s).style.fontWeigth = "bold";
document.getElementById("two").style.fontWeight = "normal"
}
function changeTwo(s)
{
document.getElementById(s).style.fontWeight = "bold";
document.getElementById("one").style.fontWeight = "normal";
}
-->
</script>
</head>
<body>
<form>
<span id="one" onClick="changeOne('one');">Hello</span>
Valid HTML has lower case attribute names so use "onclick".
<br /><br />
<span id="two" onClick="changeTwo('two');">World</span>
</form>
</body>
</html>
Any kind of help would be appreciated.
You might like to try using the HTML validator
<URL: http://validator.w3.org/>
debugging javascript is much easier with firebug even if it does make
firefox a little instable
<URL: http://getfirebug.com/>
Peter
.
- Follow-Ups:
- Re: onClick event problem
- From: Randy Webb
- Re: onClick event problem
- From: Richard Cornford
- Re: onClick event problem
- From: getsanjay . sharma
- Re: onClick event problem
- References:
- onClick event problem
- From: getsanjay . sharma
- onClick event problem
- Prev by Date: Re: Learn AJAX
- Next by Date: Re: javascript dns look up
- Previous by thread: Re: onClick event problem
- Next by thread: Re: onClick event problem
- Index(es):
Relevant Pages
|