Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4

Thread: Changing class

  1. #1
    Member Black Vivi's Avatar
    Join Date
    Apr 2003
    Location
    UK
    Posts
    75
    Member #
    1072
    How would I change the class of a certain tag using javascript?
    You can't use WHATEVER.class = "classname", and that's the only one i can think of
    Download Firebird now!

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    735
    Member #
    1935
    function changeClass() {
    document.getElementById('idName').className='newCl assName';
    return false;
    }


    <a href="#" id="idName" onClick="return changeClass();">Click to change CSS Class</a>

  4. #3
    Member Black Vivi's Avatar
    Join Date
    Apr 2003
    Location
    UK
    Posts
    75
    Member #
    1072
    thanx
    i changed what you did a bit

    here's part of my css:
    Code:
    .zoomin {
        cursor:url('./zoom_in.cur');
    }
    .zoomout {
        cursor:url('./zoom_out.cur');
    }
    here's my javascript function:
    Code:
    function resize(what)
    {
        if (what.width=="400" && what.height=="300")
        {
            what.width = "800";
            what.height = "600";
            what.className = "zoomout";
        }
        else
        if (what.width=="800" && what.height=="600")
        {
            what.width = "400";
            what.height = "300";
            what.className = "zoomin";
        }
        else
        {
            alert("JS Error!\n"+what.width+" & "+what.height);
        }
    }
    and here's what i'm using it for:
    Code:
    <img src="./<? echo($month); ?>.gif"
    alt="<? echo(ucwords($month)); ?>"
    title="Click to enlarge" border="0"
    width="400" height="300"
    onclick="resize(this);"
    class="zoomin" />
    just to show u what i needed it for
    Download Firebird now!

  5. #4
    Senior Member
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    735
    Member #
    1935
    ok, thats an interesting peice of code


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:02 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com