Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Assign Style and class

    Ok, I've got this pice of code:
    Code:
    var ourDiv=document.getElementById('cretor);
      var t=document.createElement('table');
      var tb=document.createElement('tbody');
      t.style.border='8px groove blue';
    
      var tr=document.createElement('tr');
      var td=document.createElement('td');
    Then I append and everything...
    My question:
    I want to assign a class and a style,
    the class named "asdf" and in the style, a "border-top-width of 35px" and a "border-top-style of outset, how do I put them
    THX
    EDIT:
    And if I make a button and whant to assigne it an event, let's say onClick
    Last edited by TheOne(AKA:T1); 02-07-2006 at 04:44 PM.

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    element.className='myclass';
    element.style['attribute']='somevalue'
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    Feb 2006
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    THX men
    EDIT:
    Whyyyyyyyyy!!!!!
    The class thing worked, but when I tryed this:
    t.style['border-top-width']='35px';
    it doesn't works!!!!!!
    ("t" is my element)
    Last edited by TheOne(AKA:T1); 02-07-2006 at 05:52 PM.

  • #4
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    It doesn't work because the languages allow different characters and sometimes a term used in one language is a reserved word in another.

    CSS: "border-top-color" --> JS: "borderTopColor"
    HTML: "http-equiv" --> JS: "httpEquiv"
    CSS: "float" --> JS: "cssFloat"
    HTML: "for" --> JS: "htmlFor"
    HTML&CSS: "class" --> JS: "className"
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •