Use native JS to get CLASS objects, and js to get class
I heard it is the most commonly used .... I think of dom programming art. Well-developed 5-year UI front-end framework!
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Sometimes multiple dom classes are the same. You can do this: carefully develop a five-year UI front-end framework!
var a=getElementsClass("ca"); for(var i=0;i<a.length;i++){ (function(i){ alert(a[i]) })(i) }
If there are multiple identical classes, you can use them together. If you want to achieve JQ, you can directly click the class. You also need to do some complicated processing.
How does js obtain objects based on class?
Var obj = document. getElementsByTagName ("span"); // obtain all SPAN tags first.
For (var I = 0; I <obj. length; I ++)
{
If (obj [I]. className = 'A') // find the mark of class = a in the span tag.
{
Var getObj = obj [I];
Value = getObj. innerHTML; // obtain its innerHTML
}
} // It is effective and useful, but it is stupid. I have not found any other method.
How does js obtain objects based on class?
Var obj = document. getElementsByTagName ("span"); // obtain all the SPAN tags for (var I = 0; I <obj. length; I ++) {if (obj [I]. className = 'A') // find the mark of class = a in the span mark {var getObj = obj [I]; value = getObj. innerHTML; // get his innerHTML} // or use Jquery, ext, and other JS plug-ins for processing...