10 examples of 'javascript select all elements with class' in JavaScript

Every line of 'javascript select all elements with class' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
12export function queryElementsByClass(
13 selectors: string,
14 parentNode = document
15): any {
16 return parentNode.getElementsByClassName(selectors);
17}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

67function select(selectAll) {
68 var lists = $('.deplistContent.active ul');
69 for (var i = 0; i < lists.length; i++) {
70 var checks = lists[i].getElementsByTagName('input');
71 for (var j = 0; j < checks.length; j++) {
72 if (checks[j].id === 'common') {
73 continue;
74 }
75 checks[j].checked = selectAll;
76 }
77 var lis = lists[i].getElementsByTagName('li');
78 for (var n = 0; n < checks.length; n++) {
79 if (checks[n].id === 'common') {
80 continue;
81 }
82 lis[n].className = (selectAll) ? 'active' : '';
83 }
84 }
85 updateCommand();
86 return false;
87}
134function getElements(className) {
135 var elements = [];
136 var el = document.getElementsByTagName('DIV');
137 var regexp=new RegExp("\\b"+className+"\\b");
138 for (var i = 0; i < el.length; i++)
139 {
140 if (regexp.test(el[i].className))
141 elements.push(el[i]);
142 }
143 return elements;
144}
71selectAllWithinScope() {
72 const { state, scope } = $(this).data()
73 let btnClass = 'not-checked checked'
74 $(this).data('state', !state)
75 if (!state) { btnClass = 'checked not-checked'}
76 $(this).toggleClass(btnClass)
77 $(`${scope} .j-parent`)
78 .find('.j-select-children')
79 .prop('checked', !state)
80 .trigger('change')
81}
168function getElementsByClassName (element, tag, className) {
169 return filter(element.find(tag), x => angular.element(x).hasClass(className));
170}
91function removeAllElementClass(className){
92 $("."+className, window.parent.document).removeClass(className);
93}
1function selectElement(el) {
2 const range = atom.document.createRange();
3 range.selectNodeContents(el);
4 const sel = window.getSelection();
5 sel.removeAllRanges();
6 sel.addRange(range);
7}
44function bySelectorAll(selector) {
45 return document.querySelectorAll(selector);
46}
80function selectAll() {
81 $('#trips .trip .select-trip').each(function(idx, checkbox) {
82 $(checkbox).prop('checked', true);
83 });
84 $('#selectall').prop('checked', true);
85 $('#export span').text('Export All');
86}
17function selectall(name) {
18 if ($("#check_box").attr("checked")==false) {
19 $("input[name='"+name+"']").each(function() {
20 this.checked=false;
21 });
22 } else {
23 $("input[name='"+name+"']").each(function() {
24 this.checked=true;
25 });
26 }
27}

Related snippets