[Javascript] Javascript and CSS

Information info at professionalwebpages.biz
Wed Mar 26 17:12:20 CDT 2008


Dear David,

Thank you for your response.

So there is no way that is built into JS to get classes?

Regards

Gavin
----- Original Message -----
From:    David Hucklesby +ADw-davidh126+AEA-writeme.com+AD4-
Subject: Re: +AFs-Javascript+AF0- Javascript and CSS
Date:    Wed, 26 Mar 2008 20:41:33 -00:00

On Mon, 24 Mar 2008 12:18:33 +-1100, Professional Web Pages - Information wrote:
+AD4- To whom it may concern,
+AD4-
+AD4- I am trying to obtain an element with Javascript but would also like to include certain
+AD4- classs with the element to weed out the specific element
+AD4-

Using document.getElementById() - as you suggest - will get you the
one and only element in the document having that ID. You can then
see if that element has the class name you want, like this, perhaps:

function hasClass(element, myClass) +AHs-
  var myClass +AD0- myClass.replace(/+AFw--/g, +ACIAXABc--+ACI-)+ADs-   // escape hyphens
  var re +AD0- new RegExp(+ACIAXABc-b ?+ACIAKw-myClass+-+ACIAXABc-b+ACI-)+ADs-
  if (+ACE-element.className) return false+ADs-
  return re.test(element.className)+ADs-
+AH0-


Cordially,
David
--


+AF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXw-
Javascript mailing list
Javascript+AEA-lists.evolt.org
http://lists.evolt.org/mailman/listinfo/javascript




More information about the Javascript mailing list