User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 427,221 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,263 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 970 | Replies: 6
Reply
Join Date: Mar 2008
Posts: 3
Reputation: JohnSample is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
JohnSample JohnSample is offline Offline
Newbie Poster

Accessing a class name?

  #1  
Mar 7th, 2008
Hi,

I claim First Post!


How do we access class names?

For example, this code:

<td class="the-title" align=left>The Title!</td>

If you want to parse html and find the title element you can find the class name "the-title".
That's what I am trying to do.

How do I do that?

Thank you,

Antoine
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2008
Location: Bangalore, India
Posts: 336
Reputation: DangerDev is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 32
DangerDev's Avatar
DangerDev DangerDev is offline Offline
Posting Whiz

Re: Accessing a class name?

  #2  
Mar 7th, 2008
Hi
there is no direct way to get elements by class name.
but you can access the class name attribute using dom api:
take help of following example:
  1. <html>
  2. <head>
  3. <script>
  4. function clickMe()
  5. {
  6. var aElems=document.getElementsByTagName('a');
  7. var href=aElems[0].getAttribute('href');
  8. alert('href='+href);
  9. }
  10. </script>
  11. </head>
  12. <body>
  13. <a href="javascript:clickMe();">click</a>
  14. </body>
  15. </html>
as i have done for href you can do with class. Right !!!
A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila.
~Mitch Ratcliffe
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,863
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 344
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: Accessing a class name?

  #3  
Mar 7th, 2008
Maybe a custom function like getElementsByClassName() ?
I don't accept change. I don't deserve to live.

Happiness corrupts people.

Failing to value the lives of others cheapens your own.
Reply With Quote  
Join Date: Jan 2007
Posts: 2,556
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 115
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

Re: Accessing a class name?

  #4  
Mar 7th, 2008
Just add an id, and get the element that way.
Daylight-saving time uses more gasoline
Reply With Quote  
Join Date: Mar 2008
Posts: 3
Reputation: JohnSample is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
JohnSample JohnSample is offline Offline
Newbie Poster

Re: Accessing a class name?

  #5  
Mar 7th, 2008
Originally Posted by MidiMagic View Post
Just add an id, and get the element that way.


Hi,

Actually, I am trying to parse messages from my Yahoo forum into my access 2003 database and yahoo works in a way that only allows for classes to id what you want. That's why I need to understand the DOM and figure a way through it...

Thank you

Antoine
Reply With Quote  
Join Date: Jan 2007
Posts: 2,556
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 115
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

Re: Accessing a class name?

  #6  
Mar 8th, 2008
The problem with class is that it can appear in multiple tags. That's why I use it for my color palette.

Is there some way you can use class, not to identify the tag, but to hide the identifying info from display?
Daylight-saving time uses more gasoline
Reply With Quote  
Join Date: Mar 2008
Posts: 3
Reputation: JohnSample is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
JohnSample JohnSample is offline Offline
Newbie Poster

Re: Accessing a class name?

  #7  
Mar 10th, 2008
Hi,

I don't know. It seems the class names are unique for what I am looking for so I should be good. However I still haven't found a way to parse a document in the way I need:

ex: find.class(TD)
if class="ygrp-title-name" then

Hope somebody can share a light...

Thank you,

Antoine
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 11:24 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC