HTMLElement.prototype.blur
Removes keyboard focus from the currently focused element
Syntax
element.blur()Return Value
undefined
Examples
const input = document.querySelector('input') as HTMLInputElement
input.blur()document.querySelectorAll('input').forEach(input => {
(input as HTMLInputElement).blur()
})function clearFocus() {
const active = document.activeElement as HTMLElement | null
active?.blur()
}Understanding HTMLElement.prototype.blur
The HTMLElement.prototype.blur method in JavaScript removes keyboard focus from the currently focused element. It belongs to the HTMLElement object and is one of the most widely used methods for working with htmlelement values in modern JavaScript and TypeScript applications.
The method signature is element.blur(). When called, it returns undefined. Understanding when and how to use blur() helps you write more expressive, readable code.
Common use cases for HTMLElement.prototype.blur include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like dom-focus, dom-click, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for HTMLElement.prototype.blur is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
More HTMLElement Methods
Other methods in the HTMLElement object
Related Tools
More HTMLElement Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.