469,574 Members | 1,662 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,574 developers. It's quick & easy.

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>
  3.  
  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 2364
pbmods
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';
  2.  
Aug 16 '07 #2
ty. that worked. :D
Aug 19 '07 #3
pbmods
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 suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.