Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Change text into Bold

Posted on 2001-06-08
14
228 Views
Last Modified: 2012-05-04
Hello all,

I am using the following HTML code to create a link in my page..

<DIV ID="LinkA"><A HREF=myURL" onClick= "MakeBold('LinkB')>LinkA</A></DIV>
<DIV ID="LinkB"><A HREF=myURL">Link B</A></DIV>

I want to make the link B bold when the link A is clicked? I tried to create a Java Script function, and pass the Id of the link B to it as a parameter, but what is the java script statment that change a text into bold?

Any idea?!!
Areej
0
Comment
Question by:Areej
  • 5
  • 3
  • 2
  • +3
14 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6168308
There is none.

You can change a STRING to bold by using
document.all('LinkB').innerHTML = document.all('LinkB').innerHTML.bold()
in IE

Alternatively use a stylesheet and change the class of the link

Michel
0
 

Author Comment

by:Areej
ID: 6168430
Thanx a lot..
It is working fine from Explorer, but what about Netscape?!

Many thanx,
Areej
0
 

Expert Comment

by:rogpereira
ID: 6168755
function MakeBold(l_obj) {
  document.all(l_obj).style.fontWeight = "bold";
}
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:Areej
ID: 6168847
Thanx a lot rogpereira, but that statment works only with Explorer. It is not working with Netscape. I'm getting "document.all has no properties" when I try to run it from netscape.

Any idea?!

Areej
0
 

Expert Comment

by:rogpereira
ID: 6168882
I'm sorry, but I don't work with Netscape.
0
 
LVL 9

Expert Comment

by:nimaig
ID: 6170429
You need to put your HTMLLink code in a
<DIV> or <LAYER> object and rewrite the content of the Layer everytime the Link A is clicked. That is the only possibility I know to make the thing work in Netscape.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6171209
Yep it is IE only.

So

<script>
boldText = '<A HREF="myURL"><B>Link B</B></A>'


function makeBold(divId) {
   if (document.all) {
      document.all(divId).innerHTML = boldText;
   }
   else if (document.layers) {
      with(document.layers[divId].document) {
        write(boldText);
        close()
      }
   }
   else if (document.getElementById) {
      document.getElementById(divId).innerHTML = boldText;
   }

   return false
}

<DIV ID="LinkA"><A HREF="myURL"
onClick= "return MakeBold('LinkB')>LinkA</A></DIV>
<DIV ID="LinkB" STYLE="position:absolute"><A HREF="myURL">Link B</A></DIV>

Another alternative is to have the two kinds of links in two layers and show one and hide the other

Michel
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6171210
Sorry missed a </script>
0
 
LVL 9

Expert Comment

by:nimaig
ID: 6171259
Michel -:
You missed the double quotes :
  i.e. it should be onClick= "return MakeBold('LinkB')"
and the method name must me makeBold('LinkB') not MakeBold('LinkB')

cheers :)
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6171268
yeah - thanks

Michel
0
 

Accepted Solution

by:
hjainu earned 40 total points
ID: 6175748
<html>
<head>
<style>
.c1{
font-weight:"bold"
}
</style>
<script language="javascript">

function abc()
{
i1.className="c1"
}

</script>
</head>

<body>
<a href="url"><span  onClick=abc()>A Link</span></a>
<a href="url"><span id="i1">B Link</span></a>
</body>
</html>
0
 

Author Comment

by:Areej
ID: 6178470
Thanx a lot 4 all of u.. :-)
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6178936
??????????

Michel
0
 
LVL 8

Expert Comment

by:bebonham
ID: 6199003
mplungjan...

check the other q he answered!!
???
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Generate Numbers in JQuery file 11 66
How to deal with the query string 8 37
Do alert on select 6 13
JavaScript Sort Ordering and Choice Limiting 5 17
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question