Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 51 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. // JavaScript
  2.  
  3. function getElementsByClass(searchClass,node,tag) {
  4.         var classElements = new Array();
  5.         if ( node == null )
  6.                 node = document;
  7.         if ( tag == null )
  8.                 tag = '*';
  9.         var els = node.getElementsByTagName(tag);
  10.         var elsLen = els.length;
  11.         var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  12.         for (i = 0, j = 0; i < elsLen; i++) {
  13.                 if ( pattern.test(els[i].className) ) {
  14.                         classElements[j] = els[i];
  15.                         j++;
  16.                 }
  17.         }
  18.         return classElements;
  19. }
  20.  
  21. var myCollection = getElementsByClass("myClass");
  22.  
  23.  
  24.  
  25. // jQuery
  26.  
  27. var myCollection = $(".myClass");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top