Solved

Accessing LINK properties in the DOM

Posted on 2001-06-07
6
143 Views
Last Modified: 2012-05-04
Hey,

I'm trying to change a link from an image rollover.  Doesn't seem to me that JS supports changing a links class...is there a way to switch to the hover class without rolling over the link?  Is there another way?  I'd rather not use layers, due to the x-platform differences.

Thanks,

Raydot.
0
Comment
Question by:Raydot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 50 total points
ID: 6165708
Without layers you are not going to do it in netscapes because you have to dynamically re-write with the new class designation.

For IE just use:

document.all["idname"].className="blah"

Where idname name is the value of the id attribute for the link. I think the link probably has to have a initial class value for className to exist, or you may have to wrap a div around it and use the id of the div

Cd&
 
0
 
LVL 3

Author Comment

by:Raydot
ID: 6165728
DOH, that's what I thought.  Well, I'll leave it open for a bit, if no one else has an answer I'll give you points for confirming what I said.  I was just hoping I'd missed something.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6165743
You never know. Every once in a while someone finds a new magic trick (which I quickly copy to my HD).

Cd&
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 22

Expert Comment

by:CJ_S
ID: 6166837
*LOL@Cd&*

Anyway, the way I do this is by using 2 layers. One with the main-layout, and the other one with the clicked state or mouse-over state. Both layers are exactly alike (with other words, the links and other items appear right above each other, just another color or bold or whatsoever).

Whenever needed I show the clicked-state layer. But it has a clipping rectangle set to 0,0,0,0. So, even when the layer itself is set to visible, you won't see any items. After that I am just doing a couple of calculations for which item should be shown, and set the new clipping-rectangle. Doing it this way eliminiates the need for a lot of layers for each menu-item. :-/

As you have said you do not want to use layers, but if you do want to do it this way, I might be able to give you a small sample (not from one of my projects).

regards,
CJ
0
 
LVL 3

Author Comment

by:Raydot
ID: 6167958
Right, the "webmonkey" method.  No, I knew I could do it that way, I was just wondering if I missed somthing in the JS Spec.  You know like document.links[].class or something like that...

Thanks, since CD was the one to first break me out of my little cloud, the points are his...
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6168696
Sorry we couldn't find any magic.

Thanks for the A.:^)

Cd&
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Can't get js code to execute 8 33
javascript form submition 2 22
How do i use the await event in php echo 5 19
Javascript: Range object 16 17
Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question