Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1674 How do I change text to bold using JavaScript?

You are here: irt.org | FAQ | JavaScript | DHTML | Q1674 [ previous next ]

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>

©2018 Martin Webb