473,397 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

accessing the class names for link elements through javascript

omerbutt
638 512MB
hi i
i am facing an issue like i am making a show an hide div slide show and i have to show the highlighted link with the slide now i have that so called links / pagination inside a div
Expand|Select|Wrap|Line Numbers
  1. <div id="links" class="float-left">
  2.                                 <div class="float-left"><a href="#." class="nav-button" onclick="getSlide(this.href,this);" id="link-1">1</a></div>
  3.                                 <div class="float-left"><a href="#." class="nav-button" onclick="getSlide(this.href,this);" id="link-2">2</a></div>
  4.                                 <div class="float-left"><a href="#." class="nav-button" onclick="getSlide(this.href,this);" id="link-3">3</a></div>
  5.                                 <div class="float-left"><a href="#." class="nav-button" onclick="getSlide(this.href,this);" id="link-4">4</a></div>
  6.                                 <div class="float-left"><a href="#." class="nav-button" onclick="getSlide(this.href,this);" id="link-5">5</a></div>
  7.                             </div>
  8.  
i am using a javascript statement to access that main div to make the next link highlighted (for highlighting i have a class in css sheet ) when the user clicks on the next button i am using a javascript like follows to get the curent class name of the next link it is working alright in FIREFOX but not IE 6 ,7
(didnt tested in IE 8 ) the following statement fails when i alerted it shows null , where as in FIREFOX it alerts the class name
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("links").getElementsByTagName("a")[0].getAttribute("class");
  2.  
regards,
Omer Aslam
Mar 11 '10 #1

✓ answered by omerbutt

its done it was because the

getAttribute()--- when using firefox recognises "class" as parameter (in my case as i wanted to access the classs attribute)

and

getAttribute()--- when using IE recognises "className" as parameter (in my case as i anted to access the classs attribute) , using the camel style notation
i called both of these methods as it wouldnot generate errors and it would bypass the statement that is not valid in the relevent browser
regards,
Omer Aslam

1 1826
omerbutt
638 512MB
its done it was because the

getAttribute()--- when using firefox recognises "class" as parameter (in my case as i wanted to access the classs attribute)

and

getAttribute()--- when using IE recognises "className" as parameter (in my case as i anted to access the classs attribute) , using the camel style notation
i called both of these methods as it wouldnot generate errors and it would bypass the statement that is not valid in the relevent browser
regards,
Omer Aslam
Mar 11 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Craig Anderson | last post by:
Can anyone tell me the best way to access a hidden object in a form? I could use a hard-coded index to the elements of the form, but it's too easy to add something before the hidden object and mess...
15
by: Christopher Benson-Manica | last post by:
When are named elements written with script accessible to script? <html><head><script type="text/javascript"> function ready() { alert( document.getElementsByName("div").length ); }...
5
by: Rune Runnestø | last post by:
How do I focus the cursor in the input field 'numberField' when accessing this jsp-file (or html-file) ? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head>...
18
by: Choxio | last post by:
Using ASP you can access posted form elements. Is it possible to access them from JavaScript? myHTML.htm <form action=myASP.asp> <input type=hidden id=f1 value=val1> <input type=hidden...
6
by: Chris Styles | last post by:
Dear All, I've been using some code to verify form data quite happily, but i've recently changed the way my form is structured, and I can't get it to work now. Originally : The form is...
1
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created...
7
by: Wim Roffil | last post by:
I have a simple webpage (without stylesheet) where I want to be able to switch some parts of the page off. I tried to do this by giving all the elements that should be switched off the class...
3
by: Giggle Girl | last post by:
I have inherited some CSS from a former employee that has code like this: onmouseover="this.className='highlight_on standard_border'" where it appears to activate two different classes,...
3
by: kosmodisk | last post by:
Hi, I'm having problem accessing javascript-created elements from opened window. This occurs only when I'm including another files in opened window, javascript or css. When I comment out...
6
by: Chuck Anderson | last post by:
My knowledge of JavaScript is limited. I learn from example and then adapt those examples to suit my needs. I have stumped myself on this one. I have a form with checkboxes that I want to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.