Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1674 How do I change text to bold using JavaScript?

irt.org | Knowledge Base | JavaScript | DHTML | Q1674 [ previous next ]

Q1674 How do I change text to bold using JavaScript?

Try:

<html>

<head>

<script language="JavaScript"><!--
function bold(id) {
  if (document.getElementById) {
    document.getElementById(id).style.fontWeight = 'bold';
  }
  else if (document.all) {
    document.all[id].style.fontWeight = 'bold';
  }
}
//--></script>

<p id="myPara">
some sample text <span id="mySpan">this bit will turn bold</span> but this won't.
</p>

<form>
<input type="button" value="bold" onClick="bold('mySpan')">
</form>

</body>

</html>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.