www.webdeveloper.com
Results 1 to 4 of 4

Thread: Change CSS class using javascript

  1. #1
    Join Date
    Sep 2010
    Posts
    36

    Change CSS class using javascript

    Hey everyone,

    Can anyone see why this code to change css class isn't working:

    Code:
    <script type="text/javascript">
     function unhide(show)
     {	var item= document.getElementById('name')
    item.classname='big';
    } </script>
    Been trying all morning!

    Kind regards, Mike

  2. #2
    Join Date
    Feb 2006
    Posts
    2,926
    assuming you have an element with the id 'name' and not the name attribute 'name',
    use item.className.

    javascript is case sensitive.

  3. #3
    Join Date
    Sep 2010
    Posts
    36
    Haha, so simple!

    Thanks very much.

    Kind regards, Mike

  4. #4
    Join Date
    Mar 2007
    Location
    Canada
    Posts
    99
    .. or using jquery

    Code:
    $('#name').removeClass('SomeClass').addClass('SomeNewClass');

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles