471,851 Members | 1,219 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,851 software developers and data experts.

Dynamically changing a paragraph to make it Bold

Hello everyone. I want to change the style of a HTML element. I can change the paragraph alignment to left right, justify etc. But I can seem to find the code for any other style change, for example to make a paragraph bold.

Expand|Select|Wrap|Line Numbers
  1. <p id="changealignment" class="javaw5" document.getElementByID("changealignment");>This is another paragraph.
  2. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer sed justo. Mauris ullamcorper risus nec elit. Mauris varius lacus in mauris. Sed lacinia aliquet felis. Nam lacinia tortor at orci. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer sed justo. Mauris ullamcorper risus nec elit. Mauris varius lacus in mauris. Sed lacinia aliquet felis. Nam lacinia tortor at orci.</p>
  4. <button type = "button" onclick="document.getElementById('changealignment').style.textAlign='left'">
  5. Submit - Left</button>
  6. <button type = "button" onclick="document.getElementById('changealignment').style.textAlign='right'">
  7. Submit - Right</button>
  8. <button type = "button" onclick="document.getElementById('changealignment').style.textAlign='center'">
  9. Submit - Center</button>
  10. <button type = "button" onclick="document.getElementById('changealignment').style.textAlign='justify'">
  11. Submit - Justify</button>
  12. <button type = "button" onclick="document.getElementById('changealignment').style.bold">
  13. Embolden</button>
  14. <hr width = "100%">
How can i use a button to make the above paragraph Bold? Thank you.
Aug 16 '07 #1
3 2428
5,821 Expert 4TB
Heya, Jonnie.

To make the text bold, you would use:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('changealignment').style.fontWeight = 'bold';
Aug 16 '07 #2
ty. that worked. :D
Aug 19 '07 #3
5,821 Expert 4TB
Heya, Jonnie.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Aug 19 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Free-Ed, Ltd. | last post: by
6 posts views Thread by Tim | last post: by
3 posts views Thread by Greg Scharlemann | last post: by
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.