By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,475 Members | 1,029 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,475 IT Pros & Developers. It's quick & easy.

Dynamically changing a paragraph to make it Bold

P: 35
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
Share this Question
Share on Google+
3 Replies

pbmods
Expert 5K+
P: 5,821
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

P: 35
ty. that worked. :D
Aug 19 '07 #3

pbmods
Expert 5K+
P: 5,821
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.