Online Shopping : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

40 of 48 people (83%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

How to make link bold on click, while simultaneously resetting last clicked link to normal?

Apr 4th, 2008 21:07
ha mo, Iván Rivera, Jesper Bierbum,


Note that this solution doesn't work for NS4.x (it does for NS6.x, IE4
and IE5.x).
<html>
<head>
<title>Test</title>
<script language="JavaScript">
<!--
var selectedLink;
function selectLink(lnk) {
  if (selectedLink) selectedLink.style.fontWeight='normal';
  lnk.style.fontWeight='bold';
  selectedLink=lnk;
}
//-->
</script>
</head>
<body>
<a href="#" onClick="selectLink(this)">Hello</a> <a href="#"
onclick="selectLink(this)">World!</a>
</body>
</html>
You can use as many links you like, as well as changing other CSS style
properties, simply by modifying selectLink() --change fontWeight for the
JavaScript name of any property you like to alter, and assign adequate
values.
Hope this was useful.
Iván
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com