|
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>
|
|
|
Copyright © 1996-2009 irt.org, All Rights Reserved.