Results 1 to 1 of 1

Thread: Having Link Style Default to Active Before Being Clicked On

  1. #1
    Join Date
    Aug 2009
    Posts
    39
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Question Having Link Style Default to Active Before Being Clicked On

    What I'm trying to do is to do something similar to what this person wanted on their question:
    http://www.webmasterworld.com/javascript/3338586.htm

    Instead, what I'm looking for is a way to have the links change whenever they're clicked, but to have one of the links already have the active class (which is the effect the links will have when the user clicks on it) and then have the same effect happen thereafter.

    Here is the Javascript:
    Code:
    <script type="text/javascript">
    var hrefs=document.getElementsByTagName("a");
    var hrefs=document.getElementsByClassName("links");
    var preA="";
    for(var i=0;i<hrefs.length;i++){
    hrefs[i].onclick=function(){
    if(preA!="" && preA!=this){
    preA.className="links";
    }
    this.className="active";
    preA=this;
    }
    }
    </script>
    Here is the CSS:
    Code:
    a.links:link {
    	color: #FFF;
    	text-decoration: none;
    }
    a.links:hover {
    	color: #96C;
    	text-decoration: none;
    }
    a.active {
    	color: #96C;
    	text-decoration: none;
    }
    Here is the HTML:
    Code:
    <a class="links" href="#">Curriculum Vitae</a> | <a class="links" href="#">Teaching Philosophy</a> | <a class="links" href="#">Artist Statement</a>
    I figured out the answer to my problem. You can view the source code to solving my problem on the page:
    http://gds.parkland.edu/student/fall...boutbryan.html
    Last edited by Abbster22; 10-24-2010 at 07:47 PM. Reason: The problem has been resolved.

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
  •