10 examples of 'jquery unfocus' in JavaScript

Every line of 'jquery unfocus' 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
183function unfocus() {
184 if (window.getSelection().type !== 'None') {
185 window.getSelection()
186 .removeAllRanges();
187 }
188}
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

191value: function unFocus() {
192 if (document.selection) {
193 document.selection.empty();
194 } else {
195 window.getSelection().removeAllRanges();
196 }
197}
9function focus(element) {
10 if (!isFocusable(element)) {
11 return false;
12 }
13
14 element.focus();
15 return true;
16}
23export function focusInput(element) {
24 if (!element) return;
25
26 const textNode = findLastTextNode(element);
27 if (textNode) {
28 const range = document.createRange();
29 range.setStart(textNode, textNode.length);
30 range.collapse(true);
31
32 const selection = window.getSelection();
33 selection.removeAllRanges();
34 selection.addRange(range);
35 }
36
37 element.focus();
38}
160function onBlur(e) {
161 if (!isValidFocusTarget(e.target)) {
162 return;
163 }
164
165 if (
166 e.target.classList.contains('focus-visible') ||
167 e.target.hasAttribute('data-focus-visible-added')
168 ) {
169 // To detect a tab/window switch, we look for a blur event followed
170 // rapidly by a visibility change.
171 // If we don't see a visibility change within 100ms, it's probably a
172 // regular focus change.
173 hadFocusVisibleRecently = true;
174 window.clearTimeout(hadFocusVisibleRecentlyTimeout);
175 hadFocusVisibleRecentlyTimeout = window.setTimeout(function() {
176 hadFocusVisibleRecently = false;
177 window.clearTimeout(hadFocusVisibleRecentlyTimeout);
178 }, 100);
179 removeFocusVisibleClass(e.target);
180 }
181}
43function clearFocus(n){
44 var allTags=document.getElementsByTagName('*'), i=0, e;
45 while(e=allTags[i++]){
46 if(e.id)e.blur();
47 }
48}
500focus() {
501 const el = this._getContainer();
502 if (el) {
503 el.focus();
504 }
505}
196function setFocus(target, toEnd) {
197 var state = $.data(target, "ueditor");
198 if (typeof toEnd == "boolean") {
199 return state.editor.focus(toEnd);
200 } else {
201 return state.editor.focus();
202 }
203};
235focus () {
236 this._input && this._input.focus()
237}
10function Focus(element, taskQueue) {
11 var _this = this;
12
13 _classCallCheck(this, _Focus);
14
15 this.element = element;
16 this.taskQueue = taskQueue;
17
18 this.focusListener = function (e) {
19 _this.value = true;
20 };
21 this.blurListener = function (e) {
22 if (_aureliaPal.DOM.activeElement !== _this.element) {
23 _this.value = false;
24 }
25 };
26}

Related snippets