10 examples of 'call onclick function in jquery' in JavaScript

Every line of 'call onclick function in jquery' 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
30onClick (callback) {
31 this.element.addEventListener('click', callback)
32}
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

74function divOnclickHandler(elem){
75 if (elem === document.getElementById('theDIV'))
76 window.top.eCounters["div onclick"] += 1;
77}
34onclick: function onclick(e) {
35 jQuery(this).closest('.form__field-description').parent().find('.toggle-content').toggle();
36 return false;
37}
145function onClick(e) {
146 var el = e.target
147
148 // Ignore command click, control click, and non-left click
149 if (e.metaKey || e.which !== 1) return
150
151 // Ignore if already prevented
152 if (e.defaultPrevented) return
153
154 // Also look up for parent links (<a><img></a>)
155 while (el) {
156 var url = el.href
157 if (url) {
158
159 // Ignore if created by Tracks
160 if (el.hasAttribute && el.hasAttribute('data-router-ignore')) return
161
162 // Ignore links meant to open in a different window or frame
163 if (el.target && el.target !== '_self') return
164
165 // Ignore hash links to the same page
166 var hashIndex = url.indexOf('#')
167 if (~hashIndex && url.slice(0, hashIndex) === window.location.href.replace(/#.*/, '')) {
168 return
169 }
170
171 e._tracksLink = el
172 history.push(url, true, null, e)
173 return
174 }
175
176 el = el.parentNode
177 }
178}
12function onClick (e, href) {
13 e.preventDefault()
14 window.getGlobal('openExternal')(href)
15}
75function onClick(event) {
76 event.preventDefault();
77 var self = this,
78 forward = (self.className.indexOf('pagMore') > -1),
79 parent = self.parentElement,
80 prev = (forward) ? parent.getElementsByClassName('pagLess')[0] : self,
81 prevBatch = ~~(prev.getAttribute('data-batch')),
82 next = (forward) ? self : parent.getElementsByClassName('pagMore')[0],
83 nextBatch = prevBatch + 2,
84 batch = (forward) ? nextBatch : prevBatch,
85 add = (forward ? 1 : -1),
86 id = parent.id,
87 container = parent.getElementsByTagName('ul')[0];
88
89 prev.setAttribute('data-batch', prevBatch + add);
90 next.setAttribute('data-batch', nextBatch + add);
91
92 throbber.show(self, {size: '40px'});
93
94 self.className += ' active';
95
96 nirvana.sendRequest({
97 controller: 'WikiaMobile',
98 method: 'getCategoryBatch',
99 format: 'html',
100 type: 'GET',
101 data: {
102 category: wgTitle,
103 batch: batch,
104 //this is already encoded and $.ajax encode all data
105 index: decodeURIComponent(id.slice(8))
106 }
107 }).done(
108 function (result) {
109 container.parentElement.removeChild(container);
110 next.insertAdjacentHTML('beforebegin', result);
111
112 if (forward) {
113 parent.previousElementSibling.scrollIntoView();
114 track.event('category', track.PAGINATE, {label: 'next'});
115 } else {
116 track.event('category', track.PAGINATE, {label: 'previous'});
117 }
118
119 throbber.hide(self);
120
121 prev.className = 'pagLess' + (batch > 1 ? ' visible' : '');
122 next.className = 'pagMore' + (batch < ~~(parent.getAttribute('data-batches')) ? ' visible' : '');
123 }
124 );
125}
211function clickButton(obj, render){
212 obj.disabled = true;
213 obj.value = 'Refresh the page to render again';
214 if (arguments[2]) {
215 var idToRemove = arguments[2];
216 // Remove the '#' character from the id (used in JQuery)
217 // to support prototype in these samples
218 if (idToRemove.indexOf('#') == 0) {
219 idToRemove = idToRemove.substring(1);
220 }
221 $(idToRemove).remove();
222 }
223 if (/Firefox/i.test(navigator.userAgent))
224 obj.type = 'submit';//to have buttons back when refreshing the page in FF
225 render(obj);
226}
172return function onclick(e) {
173
174 if (1 !== which(e)) {
175 return;
176 }if (e.metaKey || e.ctrlKey || e.shiftKey) {
177 return;
178 }if (e.defaultPrevented) {
179 return;
180 } // ensure link
181 var el = e.target;
182 while (el && "A" !== el.nodeName) el = el.parentNode;
183 if (!el || "A" !== el.nodeName) {
184 return;
185 } // Ignore if tag has
186 // 1. "download" attribute
187 // 2. rel="external" attribute
188 if (el.hasAttribute("download") || el.getAttribute("rel") === "external") {
189 return;
190 } // ensure non-hash for the same path
191 var link = el.getAttribute("href");
192 if (!hashbang && el.pathname === location.pathname && (el.hash || "#" === link)) {
193 return;
194 } // Check for unexpected protocols in the href, e.g. (mailto: or skype:)
195 if (link && /^[a-z]+:/.test(link) && /^https?/.test(link)) {
196 return;
197 } // check target
198 if (el.target) {
199 return;
200 } // x-origin
201 if (!sameOrigin(el.href)) {
202 return;
203 } // rebuild path
204 var path = el.pathname + el.search + (el.hash || "");
205
206 // strip leading "/[drive letter]:" on NW.js on Windows
207 if (typeof process !== "undefined" && path.match(/^\/[a-zA-Z]:\//)) {
208 path = path.replace(/^\/[a-zA-Z]:\//, "/");
209 }
210
211 var route = match(path);
212 if (!route) {
213 return;
214 }e.preventDefault();
215
216 callback(route);
217};
61function onClick() {
62 const currentTarget =
63 $navlist.find('.tabcordion_nav-item.is-active .tabcordion_nav-trigger')[0];
64 if (currentTarget != $(this)[0]) {
65 const eventData = { 'previousTarget': currentTarget, 'newTarget': $(this)[0] };
66 const event = new CustomEvent('rb.tabcordion.tabChanged', { detail: eventData });
67 $tabcordion[0].dispatchEvent(event);
68 }
69
70 setActiveAndInactive(this, $navlist);
71}
148elButton.addEventListener("click", function onClick(e) {
149 this.removeEventListener("click", onClick);
150 button.onclick(e);
151});

Related snippets