Results 1 to 3 of 3

Thread: Changing DIV Text to Bold

  1. #1

    Thread Starter
    Hyperactive Member richy's Avatar
    Join Date
    Jan 1999
    Location
    Liverpool, England
    Posts
    353

    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."

  2. #2
    Junior Member
    Join Date
    Apr 2004
    Location
    Stockholm, Sweden
    Posts
    29
    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.

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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
  •  



Click Here to Expand Forum to Full Width