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

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:

<html>
<head>
<script>
 function clickMe()
 {
	var aElems=document.getElementsByTagName('a');
	var href=aElems[0].getAttribute('href');
	alert('href='+href);
 }
</script>
</head>
<body>
 <a href="javascript:clickMe();">click</a>
</body>
</html>

as i have done for href you can do with class. Right !!!

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

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?

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

var thisClass = this.className;

I know less than nothing about javascript, but this works for me within a click function in jQuery.

This article has been dead for over six months. Start a new discussion instead.