Results 1 to 3 of 3

Thread: JavaScript : Set Text Font to Bold at Runtime

  1. #1

    Thread Starter
    Hyperactive Member Coool's Avatar
    Join Date
    Feb 2006
    Location
    System.Coool
    Posts
    333

    Unhappy JavaScript : Set Text Font to Bold at Runtime

    Hi I have one textbox named txtName and I want to make it's style to bold and regular at runtime in onFoucs event.

    I used this but no result...
    document.Form1.txtName.style.font.bold=true;
    I am using .NET 2010 with Windows 7

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: JavaScript : Set Text Font to Bold at Runtime

    Code:
    var txtName = document.getElementById('txtName');
    if(txtName) { txtName.style.fontWeight = 'bold'; }
    The element must have id="txtName" attribute for this to work.

    For more details on CSS see W3C CSS property index; JavaScript uses the same names, except that properties with - character don't have it, instead the next character will be upper case. (ie. font-weight -> fontWeight).

  3. #3

    Thread Starter
    Hyperactive Member Coool's Avatar
    Join Date
    Feb 2006
    Location
    System.Coool
    Posts
    333

    Re: JavaScript : Set Text Font to Bold at Runtime

    Thanks u very much Merri..
    I am using .NET 2010 with Windows 7

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