Re: onClick event problem



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

.



Relevant Pages

  • Re: onClick event problem
    ... the user clicks on one of the two span tags, ... that the first one loses its highlight. ... HTML is case insensitive. ... (Javascript cares, but HTML doesn't). ...
    (comp.lang.javascript)
  • Re: OE6 HowTo Highlight text to send?
    ... Appreciate everyone's time in helping. ... Just make sure the SPAN tag surrounds the text you wish highlighted in a HTML formatted message. ... > AVG free antivirus http://www.grisoft.com ... > ready to send, use the left mouse key and highlight the word, or phrase, ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: OE6 HowTo Highlight text to send?
    ... Just make sure the SPAN tag surrounds the text you wish highlighted in a HTML formatted message. ... AVG free antivirus http://www.grisoft.com ... ready to send, use the left mouse key and highlight the word, or phrase, ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: I want to remove these: > (looks like a greater than sign in math)
    ... What worked, and I guess you meant Suzanne, was to highlight one of the>s, while holding down the alt key+ then click the clear formatting button and drag up your highlighting which will then be limited to the narrow vertical column contianing the>s. ... I don't know the name of these:> I assume they're part of a basic html tag, and hopefully someone will educate me. ...
    (microsoft.public.word.newusers)
  • Re: OE6 HowTo Highlight text to send?
    ... when sending html mail choose ... Source Edit ... AVG free antivirus http://www.grisoft.com ... ready to send, use the left mouse key and highlight the word, or phrase, ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)