congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo For Javascript
Document.getElementsByClassName
Code IndexAdd Tabnine to your IDE (free)

How to use
getElementsByClassName
function
in
Document

Best JavaScript code snippets using builtins.Document.getElementsByClassName(Showing top 15 results out of 1,530)

origin: Automattic/wp-calypso

/**
           * Unhide .hidden suites.
           */
          function unhide() {
            var els = document.getElementsByClassName( 'suite hidden' );
            for ( var i = 0; i < els.length; ++i ) {
              els[ i ].className = els[ i ].className.replace( 'suite hidden', 'suite' );
            }
          }
origin: DavidAnson/markdownlint

// Handle violation navigation
 function onLineNumberClick(e) {
  var line = document.getElementById("l" + e.target.textContent);
  if (line) {
   var highlighted = document.getElementsByClassName("highlight");
   Array.prototype.forEach.call(highlighted, function forElement(element) {
    element.classList.remove("highlight");
   });
   line.classList.add("highlight");
   line.scrollIntoView();
   e.preventDefault();
  }
 }
origin: shen100/mili

function() {
  if (window.user) {
    const navbarUserArr = document.getElementsByClassName('navbar-user');
    if (!navbarUserArr || !navbarUserArr[0]) {
      return;
    }
    new Vue({
      render: h => h(UserDropdown, {
        props: {
          userID: window.user.id,
          avatarURL: window.user.avatarURL,
          menuAlign: 'right'
        },
      }),
    }).$mount('.navbar-user');
  }
}()
origin: Automattic/wp-calypso

const render = () => {
  ReactDOM.render(
    React.createElement( AuthWrapper( Notifications ), {
      clientId: 56641,
      customEnhancer,
      customMiddleware,
      isShowing,
      isVisible,
      locale,
      receiveMessage: sendMessage,
      redirectPath: '/',
    } ),
    document.getElementsByClassName( 'wpnc__main' )[ 0 ]
  );
}
origin: shen100/mili

function() {
  function setArticleSidebarPosition() {
    const sidebar = document.getElementsByClassName('side-box')[0];
    const scrollTop = getScrollPos().scrollTop;
    let top = 124 - scrollTop;
    top = top > 57 + 20 ? top : 57 + 20;
    sidebar.style.top = top + 'px';
  }

  window.addEventListener('scroll', function() {
    setArticleSidebarPosition();
  });
  window.addEventListener('resize', function() {
    setArticleSidebarPosition();
  });
}()
origin: lirantal/dockly

handleClick(e) {
    e.preventDefault();
    let elem = 0;
    let scroll = true;
    const { type, element, offset, timeout } = this.props;
    if (type && element) {
      switch (type) {
        case 'class':
          elem = document.getElementsByClassName(element)[0];
          scroll = elem ? true : false;
          break;
        case 'id':
          elem = document.getElementById(element);
          scroll = elem ? true : false;
          break;
        default:
      }
    }
    scroll ? ( this.scrollTo(elem, offset, timeout) ) : console.log(`Element not found: ${element}`); // eslint-disable-line
  }
origin: princejwesley/Mancy

onDrag(e) {
  let replConsole = document.getElementsByClassName('repl-console')[0];
  let replConsoleEnv = document.getElementsByClassName('repl-console-environment')[0];

  let {clientY} = e;
  let {height} = document.defaultView.getComputedStyle(replConsoleEnv);
  let initHeight = parseInt(height, 10);

  let startDrag = (e) => {
   let adj = e.clientY - clientY;
   replConsoleEnv.style.flex = `0 0  ${(initHeight - adj)}px`;
  }

  let stopDrag = (e) => {
   document.documentElement.removeEventListener('mousemove', startDrag, false);
   document.documentElement.removeEventListener('mouseup', stopDrag, false);
  }

  document.documentElement.addEventListener('mousemove', startDrag, false);
  document.documentElement.addEventListener('mouseup', stopDrag, false);
 }
origin: vitaly-t/pg-promise

/*global document */
(function() {
  var source = document.getElementsByClassName('prettyprint source linenums');
  var i = 0;
  var lineNumber = 0;
  var lineId;
  var lines;
  var totalLines;
  var anchorHash;

  if (source && source[0]) {
    anchorHash = document.location.hash.substring(1);
    lines = source[0].getElementsByTagName('li');
    totalLines = lines.length;

    for (; i < totalLines; i++) {
      lineNumber++;
      lineId = 'line' + lineNumber;
      lines[i].id = lineId;
      if (lineId === anchorHash) {
        lines[i].className += ' selected';
      }
    }
  }
})();
origin: Automattic/wp-calypso

/**
           * Check for suites that do not have elements
           * with `classname`, and hide them.
           *
           * @param {text} classname
           */
          function hideSuitesWithout( classname ) {
            var suites = document.getElementsByClassName( 'suite' );
            for ( var i = 0; i < suites.length; i++ ) {
              var els = suites[ i ].getElementsByClassName( classname );
              if ( ! els.length ) {
                suites[ i ].className += ' hidden';
              }
            }
          }
origin: shen100/mili

function() {
  function setRightSidebarPosition() {
    const sidebar = document.getElementsByClassName('home-sidebar')[0];
    const scrollTop = getScrollPos().scrollTop;
    let top = 124 - scrollTop;
    top = top > 57 + 20 ? top : 57 + 20;
    sidebar.style.top = top + 'px';
  }

  window.addEventListener('scroll', function() {
    setRightSidebarPosition();
  });
  window.addEventListener('resize', function() {
    setRightSidebarPosition();
  });
}()
origin: princejwesley/Mancy

onDrag(e) {
  let replConsole = document.getElementsByClassName('repl-console')[0];
  let replContainerRight = document.getElementsByClassName('repl-container-right')[0];

  let {clientX} = e;
  let {width} = document.defaultView.getComputedStyle(replConsole);
  let initWidth = parseInt(width, 10);

  let startDrag = (e) => {
   let adj = e.clientX - clientX;
   replContainerRight.style.flex = '0 0  ' + (initWidth - adj) + 'px';
  }

  let stopDrag = (e) => {
   document.documentElement.removeEventListener('mousemove', startDrag, false);
   document.documentElement.removeEventListener('mouseup', stopDrag, false);
  }

  document.documentElement.addEventListener('mousemove', startDrag, false);
  document.documentElement.addEventListener('mouseup', stopDrag, false);
 }
origin: shen100/mili

function() {
  function setArticleSidebarPosition() {
    const sidebar = document.getElementsByClassName('side-box')[0];
    const scrollTop = getScrollPos().scrollTop;
    let top = 124 - scrollTop;
    top = top > 57 + 20 ? top : 57 + 20;
    sidebar.style.top = top + 'px';
  }

  window.addEventListener('scroll', function() {
    setArticleSidebarPosition();
  });
  window.addEventListener('resize', function() {
    setArticleSidebarPosition();
  });
}()
origin: shen100/mili

function() {
  function setRightSidebarPosition() {
    const sidebar = document.getElementsByClassName('home-sidebar')[0];
    const scrollTop = getScrollPos().scrollTop;
    let top = 124 - scrollTop;
    top = top > 57 + 20 ? top : 57 + 20;
    sidebar.style.top = top + 'px';
  }

  window.addEventListener('scroll', function() {
    setRightSidebarPosition();
  });
  window.addEventListener('resize', function() {
    setRightSidebarPosition();
  });
}()
origin: shen100/mili

function() {
  if (window.user) {
    const navbarUserArr = document.getElementsByClassName('navbar-user');
    if (!navbarUserArr || !navbarUserArr[0]) {
      return;
    }
    new Vue({
      render: h => h(UserDropdown, {
        props: {
          userID: window.user.id,
          avatarURL: window.user.avatarURL,
          menuAlign: 'right'
        },
      }),
    }).$mount('.navbar-user');
  }
}()
origin: lirantal/dockly

handleClick(e) {
    e.preventDefault();
    let elem = 0;
    let scroll = true;
    const { type, element, offset, timeout } = this.props;
    if (type && element) {
      switch (type) {
        case 'class':
          elem = document.getElementsByClassName(element)[0];
          scroll = elem ? true : false;
          break;
        case 'id':
          elem = document.getElementById(element);
          scroll = elem ? true : false;
          break;
        default:
      }
    }
    scroll ? ( this.scrollTo(elem, offset, timeout) ) : console.log(`Element not found: ${element}`); // eslint-disable-line
  }
builtins(MDN)DocumentgetElementsByClassName

JSDoc

collection = element . getElementsByClassName(classNames)

Most used builtins functions

  • Console.log
  • Console.error
  • Promise.then
    Attaches callbacks for the resolution and/or rejection of the Promise.
  • Promise.catch
    Attaches a callback for only the rejection of the Promise.
  • Array.push
    Appends new elements to an array, and returns the new length of the array.
  • Array.length,
  • Array.map,
  • String.indexOf,
  • fetch,
  • Window.location,
  • Window.addEventListener,
  • ObjectConstructor.keys,
  • Array.forEach,
  • Location.reload,
  • Response.status,
  • Navigator.serviceWorker,
  • ServiceWorkerContainer.register,
  • ServiceWorkerRegistration.installing,
  • ServiceWorkerContainer.controller

Popular in JavaScript

  • async
    Higher-order functions and common patterns for asynchronous code
  • ms
    Tiny millisecond conversion utility
  • through2
    A tiny wrapper around Node.js streams.Transform (Streams2/3) to avoid explicit subclassing noise
  • http
  • crypto
  • ws
    Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js
  • redis
    Redis client library
  • mkdirp
    Recursively mkdir, like `mkdir -p`
  • semver
    The semantic version parser used by npm.
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now