[Javascript] Javascript and CSS
David Hucklesby
davidh126 at writeme.com
Wed Mar 26 21:02:09 CDT 2008
On Wed, 26 Mar 2008 22:12:20 +0000, GT wrote:
> Dear David,
>
> Thank you for your response.
>
> So there is no way that is built into JS to get classes?
>
JavaScript "element.className" returns the value of all classes defined
on "element", but for getting all elements having a certain class then,
no, there is no built-in JavaScript function. Plenty of solutions exist
if you need one - google "javascript getelements by class name"
for a few.
In your example problem, though, you don't need this. An ID is, by
definition, unique in a document, so using getElementById() then
checking its className value(s) should work just fine.
Cordially,
David
--
More information about the Javascript
mailing list