10 examples of 'jquery initialization' in JavaScript

Every line of 'jquery initialization' 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
20function onJqueryLoad() {
21 $(document).ready(function() {
22 $("button").click(function() {
23 setTimeout(function() {
24 // There might be several email windows. Each of
25 // them has a textfield with id em-0, em-1, ..
26 $("div[id^='aD-']").one('click', addSignature)
27 .one('focusin', addSignature);
28 }, 100);
29 });
30 });
31}
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

1function jqueryLoaded() {
2 django.jQuery(document).ready(function () {
3 if (!django.hasOwnProperty('unitsList')){
4 django.jQuery.ajax({
5 url: '/api/v1/courses/units',
6 success: function (data, status, jqXHR) {
7 django.unitsList = data
8 }
9 });
10 }
11 });
12}
5function init() {
6 $(document).ready(function () {
7 /*
8 if there are no vegan dishes in the dropdown box,
9 hide the dropdown box, and hide the text that says
10 "if unlisted"
11 */
12 if ($("div.vegan-dish-choices select option").length <= 1) {
13 $("div.vegan-dish-choices").hide();
14 }
15 });
16}
5init: function init()
6{
7 // define qunit menu
8 var qm = "";
9 qm += "<div id=\"qunit-menu\">";
10 qm += "<ul class=\"qunit-menu\">";
11 qm += "<li><b>Shortcuts (shift + ):</b></li>";
12 qm += "<li><b>?</b> - shows/hides the menu</li>";
13 qm += "<li><b>s</b> - shows qunit overlay</li>";
14 qm += "<li><b>h</b> - hides qunit overlay</li>";
15 qm += "<li><b>a</b> - runs all tests</li>";
16 qm += "<li><b>t</b> - shows/hides tests</li>";
17 qm += "</ul>";
18 qm += "</div>";
19
20 // define qunit results
21 var qr = "";
22 qr += "<div id=\"qunit-results\">";
23 qr += "<h1 id=\"qunit-header\">Results</h1>";
24 qr += "<h2 id=\"qunit-banner\"></h2>";
25 qr += "<h2 id=\"qunit-userAgent\"></h2>";
26 qr += "<br /><img id=\"qunit-loading\" src=\"/images/i_loading_bar.gif\" alt=\"loading\">";
27 qr += "<ol id=\"qunit-tests\"></ol>";
28 qr += "</div>";
29
30 // define qunit-overlay
31 var qo = "";
32 qo += "<div id=\"qunit-overlay\">";
33 qo += "<div id=\"qunit-test-options\">";
34 qo += "<ul class=\"qunit\">";
35 qo += "<li class=\"first\"><a id=\"qunit-all-tests\" href=\"#\">Run All Tests</a></li>";
36 qo += "<li class=\"last\">Or Choose A Test: " + $collection;
37 qo += "</ul>";
38 qo += "<img src=\"/images/bg_secondaryNav_right.gif\">";
39 qo += "</div>";
40 qo += qm;
41 qo += "<div id=\"qunit-logo\">";
42 qo += "JavaScript testing powered by: <a href=\"http://docs.jquery.com/QUnit\">";
43 qo += "<img src=\"/images/l_qunit.png\" alt=\"qunit\" border=\"0\"></a></div>";
44 qo += "</div>";
45 qo += qr;
46 qo += "<div style='clear:both;'></div>";
47
48 $("body").prepend(qo);
49},
3$(function initialize() {
4 $('#add-todo').on('submit', addTodo);
5 $('#clear-completed').on('click', clearCompleted);
6
7 $.getJSON('todos.json')
8 .then(function(todos) {
9
10 todosService = new TodosService(todos);
11
12 render();
13
14 $('.loading').hide();
15 $('.container.hidden').show();
16 });
17});
13function init() {
14 ui.Finder.id = '#finder_bar';
15 ui.Finder.tbox = '#tbox_finder';
16 $(ui.Finder.tbox).keyup(
17 function (event) {
18 if (event.keyCode == 13) { // Enter to search
19 var query = $.trim($(ui.Finder.tbox).val());
20 if (query.length == 0)
21 return;
22 if (ui.Finder.query != query) {
23 ui.Finder.search(query);
24 ui.Finder.next_result();
25 } else {
26 ui.Finder.next_result();
27 }
28 } else if (event.keyCode == 27) { //ESC to close
29 $('#btn_finder_close').click();
30 return false;
31 }
32 });
33 $('#btn_finder_next').click(
34 function (event) {
35 ui.Finder.next_result();
36 return false;
37 });
38 $('#btn_finder_prev').click(
39 function (event) {
40 ui.Finder.prev_result();
41 return false;
42 });
43 $('#btn_finder_close').click(
44 function (event) {
45 ui.Finder.clear();
46 ui.Finder.hide();
47 return false;
48 });
49 return this;
50},
23init: function init() {
24
25 // Let's check if the browser supports notifications
26 if (!('Notification' in window)) {
27 console.info('This browser does not support desktop notification');
28 return;
29 }
30
31 // store default page title
32 this.set('defaultTitle', $('title') );
33
34 var permission = this.hasPermissions();
35 if( permission ) {
36 if( permission === 'granted') {
37 // can notify
38 } else {
39 this.requestPermission();
40 }
41 }
42},
10jQuery(function ready() {
11 var node = $("#child"), dsName;
12
13 jQuery.each([".zoo", "#zoo", "[data-foo=zoo]", "#nonexistant"], function(i, item) {
14setTimeout(function(){
15 dsName = "find '" + item + "'";
16 jQuery("#results").append("<li>rooted " + dsName + "<ul>" +
17 "<li>new: " + benchmarkString("$('body').find('" + item + "')", 250, dsName) + "</li>" +
18 "<li>old: " + benchmarkString("old('body').find('" + item + "')", 250, dsName) + "</li>" +
19 "</ul></li>");
20}, 100);
21 });
22 });
10jQuery(function ready() {
11 var node = $("#child"), name;
12
13 jQuery.each([".zoo", "#zoo", "[data-foo=zoo]", "#nonexistant"], function(i, item) {
14 setTimeout(function(){
15 name = "filter '" + item + "'";
16 jQuery("#results").append("<li>" + name + "<ul>" +
17 "<li>new: " + benchmarkString("$('div').filter('" + item + "')", 100, name) + "</li>" +
18 "<li>old: " + benchmarkString("old('div').filter('" + item + "')", 100, name) + "</li>" +
19 "</ul></li>");
20 jQuery("#results").append("<li>single " + name + "<ul>" +
21 "<li>new: " + benchmarkString("$('#nonexistant').filter('" + item + "')", 1000, name) + "</li>" +
22 "<li>old: " + benchmarkString("old('#nonexistant').filter('" + item + "')", 1000, name) + "</li>" +
23 "</ul></li>");
24 }, 100);
25 });
26 });
10jQuery(function ready() {
11 var node = $("#child"), name;
12
13 jQuery.each([".zoo", "#zoo", "[data-foo=zoo]", "#nonexistant"], function(i, item) {
14 setTimeout(function(){
15 name = "closest '" + item + "'";
16
17 jQuery("#results").append("<li>" + name + "<ul>" +
18 "<li>new: " + benchmarkString("$('#child').closest('" + item + "')", 2500, name) + "</li>" +
19 "<li>old: " + benchmarkString("old('#child').closest('" + item + "')", 2500, name) + "</li>"
20 + "</ul></li>");
21 }, 100);
22 });
23 });

Related snippets