SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2001
    Location
    Portland, OR
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    OnMouseOver to change id?

    so i was wondering if anyone knows a way to use the OnMouseOver function to change the id of an element? i am trying to 360 an href in my script, so that the id changes from

    #original { background-color: #000000;
    color: #ee9900;
    }

    to

    #changed { background-color: #ee9900;
    color: #000000;
    }

    does anyone know if this is possible?

    thanks!

  2. #2
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By it's very nature, you can't change an ID. It owuld be like changing your name. The ID is how you would reference the item to begin with.

    You might be able to change it's class though.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This method will work with IE5+ and Netscape 6


    <div id="original" onmouseover="this.setAttribute('id','changed')">some text</div>

  4. #4
    SitePoint Enthusiast
    Join Date
    Sep 2001
    Location
    Portland, OR
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for showing me that-- what about that whole changing the class thing? to be hones that didn't occur to me (duh!) how would i go about doing that?
    thanks!

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <style>
    .original { background-color: #000000;
    color: #ee9900;
    }

    .changed { background-color: #ee9900;
    color: #000000;
    }

    </style>

    <div class="original" onmouseover="this.setAttribute('className','changed')">some text</div>


Bookmarks

Posting Permissions

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