layout | tags |
---|---|
doc-api.html |
argument-list |
Shifts focus away from an element if it currently has focus.
The blur()
method is available on all HTMLElement
. But this is not necessarily true for SVGElement
. Only Blink and WebKit expose the blur()
method on SVG elements, Gecko, Trident and Edge do not. This will likely change once SVG 2 is a thing. Until then ally.element.blur()
tries to apply HTMLElement.prototoype.blur
to SVGElement
s. This only works for Internet Explorer 9 - 11, as Gecko and Edge actively prevent this.
According to jQuery Bug 9420 calling blur()
on the body
element may make the browser window lose focus. ally.element.blur()
guards against this.
var element = document.getElementById('victim');
var result = ally.element.blur(element);
Name | Type | Default | Description |
---|---|---|---|
element | <selector> |
required | The Element to blur. First element of the collections is used. |
HTMLElement
that received focus (usually document.body
) or null
if focus could not be shifted.
TypeError
if element
argument does not resolve to an HTMLElement
.
- Added in
v1.3.0
. - Since
v1.4.0
can blur SVG elements in Firefox, Internet Explorer and Edge.
:::warning Cannot blur SVG and MathML elements when they're not children of an HTML document. :::
ally.element.focus
shifts focus to an element if it does not already have focus.