Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Re assign Style Sheet Class!!!


Message #1 by "Andrew Scott" <Andrew@c...> on Thu, 28 Jun 2001 17:13:18
you can assign them explicitly... or you can use the "this" keyword to get
hold of the object reference

<a href="..." onclick="linkClick(this)">...</a>


<script language="javascript">

//variable to hold onto reference between clicks
var oLink = null;

function linkClick(oLinkClicked){
	if(oLink!=null) oLink.className="standardlink";
	oLinkClicked.className="clickedlink";
	oLink = oLinkClicked;
}
</script>



-----Original Message-----
From: Andrew Scott [mailto:Andrew@c...]
Sent: 28 June 2001 18:57
To: javascript
Subject: [javascript] RE: Re assign Style Sheet Class!!!


GREAT!!!!! thanks LOADS

Now how do i find out the names/ids of all the <a> tags on a page?

> object.className="class"
> 
> -----Original Message-----
> From: Andrew Scott [mailto:Andrew@c...]
> Sent: 28 June 2001 18:13
> To: javascript
> Subject: [javascript] Re assign Style Sheet Class!!!
> 
> 
> Hi all
> 
> Does anyone know how to reassign a class to a object on the page using 
> Javascript??
> 
> Basically... I have 30 or so text links on a page that have a class 
> assigned to it to color it and when the link is clicked it loads a page 
> into a diferent frame and I want the link that was clicked to change 
> color, without re-loading the page, then to be setback to the original 
> color when another linked is clicked.
> 
>   
> ---------- HTML --------------------
> <a href="javascript:test('LinkRef1')" class="class1" 
> name="LinkRef1">LINK1</a>
> 
> <a href="javascript:test('LinkRef2')" class="class1" 
> name="LinkRef1">LINK2</a>
> 
> <a href="javascript:test('LinkRef3')" class="class1" 
> name="LinkRef1">LINK3</a>
> --------- END HTML -----------------
> 
> ----------- J Script ----------------
> 
> function test()
> {
>    tmp = eval(pass)
>    alert(tmp.style) // this returns an object... 
>                     //but I want to assign another class to the Link 
here!
> 
>    parent.main.location  = "blar.asp"
> 
> }
> 
> ------------- end j script -------
> 
> HELP!!!!!!!!!!!!!!1111


  Return to Index