|
-
Jun 3rd, 2004, 04:48 AM
#1
Thread Starter
Hyperactive Member
Changing DIV Text to Bold
I'm trying to get my Javascript to toggle text in a div to bold and back but I can't find the function to do this. Can anyone help?
Thanks very much
ASP, PHP, VB, JavaScript, CSS, HTML, a little C and a little CGI.
Richard Whitehouse.
Join the Footie Predictions League
"Make it idiot proof and someone will make a better idiot."
-
Jun 3rd, 2004, 04:59 AM
#2
Junior Member
I don't know javascript, that is, I don't know the exact syntax to use, but I've seen examples of JavaScript controlling CSS-attributes.
Somethin along these lines
Code:
getElementByID("div").style.font-weight: bold;
If that's not the correct function and/or syntax, I'm sorry, but it should give you something to go on.
If there is a way to solve your problems, there is no need to worry; if there is no way to solve your problems, there is no point to worry.
-
Jun 4th, 2004, 06:34 AM
#3
It's almost correct, but you need to translate the names of the CSS properties. Every - in the name gets removed and the next character becomes uppercase, e.g.
font-weight -> fontWeight
And of course you need JavaScript-style assignment, that is
document.getElementById('thediv').style.fontWeight = "bold";
There are far more complicated ways to do other interesting things too, but they don't work in IE so they're usually not interesting.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|