10 examples of 'jquery loop through elements' in JavaScript

Every line of 'jquery loop through elements' 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
66function jQueryGenericLoop (elements, cache) {
67 $.each( cache, function ( key, val ) {
68 if ( val.handle ) {
69 jQueryGeneric(elements, val, val.handle.elem);
70 }
71 } );
72}
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

270var _loop = function _loop(i) {
271 var attr = elements[i].getAttribute("on");
272 var action = elements[i].getAttribute("action");
273 elements[i].addEventListener(attr, function () {
274 eval(action);
275 });
276};
20var _loop = function _loop(i) {
21 var link = links[i];
22 if (link.rel === 'preload' && link.getAttribute('as') === 'style') {
23 w.onloadCSS(w.loadCSS(link.href, link, link.getAttribute('media')), function () {
24 return SHORTBREAD_INSTANCE.loaded(link.id);
25 });
26 link.rel = null;
27 }
28};
6function each(els, callback) {return Array.prototype.forEach.call(els, callback);}
21(function animLoop() {
22 webkitRequestAnimationFrame(animLoop);
23 if($(container).parents('.filter_view').hasClass('selected')) {
24 containerTop = container.offset().top;
25 headerOrigin = header.offset().top;
26 headerHeight = header.outerHeight();
27 containerHeight = container.outerHeight();
28 containerTop = container.offset().top;
29 containerSize = container.outerHeight();
30 pageOffset = $(window).scrollTop() + settings.padding;
31 containerBottom = containerHeight + containerTop;
32
33 if(!header.parent('.state').hasClass('collapsed')) {
34 if (pageOffset < containerTop && placeholder != undefined) {
35 if (placeholder != undefined) {
36 placeholder.remove();
37 placeholder = undefined;
38 header.css(originalCss);
39 header.removeClass('stuck');
40 }
41 }
42 else if (pageOffset > containerTop && pageOffset < (containerBottom - headerHeight) && $(window).scrollTop() > 0) {
43 if (placeholder == undefined) {
44 placeholder = $('<div/>')
45 .css('height', headerHeight + 'px')
46 .addClass('placeholder')
47 .css('width', 732);
48 header.before(placeholder);
49 header.css('width', 732);
50 header.addClass('stuck');
51 }
52 callback(header);
53 header.css('position', 'fixed');
54 header.css('top', settings.padding + 'px');
55 }
56 else if (pageOffset > (containerBottom - headerHeight)) {
57 header.css('top', (containerBottom - headerHeight) - pageOffset + settings.padding + 'px');
58 }
59 }
60 }
61})();
203var _loop = function _loop(i) {
204 items[i].onclick = function () {
205 if (items[i].parentNode.classList.contains('disabled')) {
206 return false;
207 }
208 self.dispatchEvent(new CustomEvent('pf-dropdown.itemClicked', {}));
209 return true;
210 };
211};
257var _loop2 = function _loop2(i) {
258 var el = contentEls[i];
259 var d = 50 + Math.round(Math.random() * 350);
260 var transform = {
261 translateX: Math.round(Math.random() * 40 - 20)
262 };
263 var more = el.getAttribute('data-idx') <= 3;
264 dynamics.css(el, transform);
265 dynamics.setTimeout(function () {
266 dynamics.css(el, {
267 display: ''
268 });
269 }, d);
270 maxDelay = Math.max(maxDelay, d);
271 dynamics.setTimeout(function () {
272 dynamics.css(el, {
273 translateX: Math.round(transform.translateX / -5)
274 });
275 }, d + 100);
276 dynamics.setTimeout(function () {
277 dynamics.css(el, {
278 translateX: 0,
279 translateY: 0
280 });
281 if (!more) {
282 el.parentNode.removeChild(el);
283 }
284 }, d + 150);
285 if (more) {
286 dynamics.setTimeout(function () {
287 dynamics.css(el, {
288 translateX: Math.round(transform.translateX / -2)
289 });
290 }, d + 300);
291 dynamics.setTimeout(function () {
292 el.parentNode.removeChild(el);
293 }, d + 550);
294 }
295};
206function forEachDomElement(selector, callback) {
207 var elements = document.querySelectorAll(selector)
208 return Array.prototype.forEach.call(elements, callback)
209}
81_each (elements, cb) {
82 [].forEach.call(elements, cb)
83}
110function forEach(elements, callback) {
111 Array.prototype.forEach.call(elements, callback);
112}

Related snippets