zjrJS.Doc.hC() - Beta Test Suite for zjrJS

This information lives on a webpage hosted at the following web address: 'https://www.omegajunior.net/code/zjrjs/beta.php'.

How to use zjrJS.Doc.hC() ("has class")

Used zjrJS Version:

Stable Minified version 20141202t2322 of zjrJS.

There is no newer Beta version available.


 

Declaration
zjrJS.Doc.hC(String className, HtmlElement Target)

Goal
A cross-browser method to detect CSS classes in elements.

Typical usage
When you need to retrieve elements based on their CSS class, or need to filter elements from a nodelist based on their CSS class.

Member Type
Function.

Value Type
Boolean (true or false). True when the target HtmlElement's class attribute equals or contains the supplied className. False in any other case.

Parameters
String className: any valid CSS class name to detect. Mind you that you are responsible for choosing names that work.
HtmlElement Target: the element (either generated (Doc.cE() or document.createElement()) or retrieved (Doc.eid() or document.getElementByID() etc.)) of which the class attribute needs inspection.

Dependencies
None.

Example
<script type="text/javascript" src="zjrJS.version.js" id="zjrJS"></script>
<script type="text/javascript">/* <![CDATA[ */
zjrJS.Doc.aE(window,"load",function(){
//reference the Doc object
var D=zjrJS.Doc;
//retrieve all HtmlParagraphElements
var P=D.etn("p");
if(P){
for(var i=0, j=P.length; i<j; i++){
if(D.hC("bigFont", P[ i ])){
alert(i);
}
}
}
//clean up memory
D=P=null;
});
/* ]]> */</script>


Hint
If you find yourself using this a lot, you have chosen the wrong API. You should have chosen JQuery instead.

Download:

Download zjrJS’ latest stable build (20141202t2322) minified (7.1KB).

Download zjrJS’ latest stable build (20141202t2322) (11.9KB).