• Skip to main content
  • Skip to search
  • Skip to select language
  • References
    • Overview / Web Technology

      Web technology reference for developers

    • HTML

      Structure of content on the web

    • CSS

      Code used to describe document style

    • JavaScript

      General-purpose scripting language

    • HTTP

      Protocol for transmitting web resources

    • Web APIs

      Interfaces for building web applications

    • Web Technology

      Web technology reference for developers

  • Guides
    • Overview / MDN Learning Area

      Learn web development

    • MDN Learning Area

      Learn web development

    • HTML

      Learn to structure web content with HTML

    • CSS

      Learn to style content using CSS

    • JavaScript

      Learn to run scripts in the browser

    • Accessibility

      Learn to make the web accessible to all

  • MDN Plus
    • Overview

      More MDN. Your MDN.

    • FAQ

      Frequently asked questions about MDN Plus

  • Already a subscriber?
  • Get MDN Plus
  1. Tecnología para desarrolladores web
  2. Referencia de la API Web
  3. Document
  4. element.hasFocus

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

Related Topics

  1. Document
  2. Constructor
    1. Document() (en-US)
  3. Propiedades
    1. activeElement (en-US)
    2. Deprecated alinkColor
    3. Deprecated all (en-US)
    4. Deprecated anchors
    5. Deprecated applets
    6. Deprecated bgColor
    7. body
    8. characterSet
    9. childElementCount (en-US)
    10. children (en-US)
    11. compatMode (en-US)
    12. contentType
    13. currentScript (en-US)
    14. defaultView
    15. designMode
    16. dir
    17. doctype
    18. documentElement
    19. documentURI
    20. Deprecated domain (en-US)
    21. embeds
    22. Deprecated fgColor (en-US)
    23. firstElementChild (en-US)
    24. forms (en-US)
    25. Deprecated fullscreen (en-US)
    26. fullscreenElement (en-US)
    27. fullscreenEnabled (en-US)
    28. head
    29. Deprecated height
    30. hidden
    31. images (en-US)
    32. implementation (en-US)
    33. lastElementChild (en-US)
    34. lastModified (en-US)
    35. Deprecated lastStyleSheetSet (en-US)
    36. Deprecated linkColor (en-US)
    37. links (en-US)
    38. location (en-US)
    39. Non-Standard mozSyntheticDocument (en-US)
    40. Experimental Deprecated origin (en-US)
    41. pictureInPictureElement (en-US)
    42. pictureInPictureEnabled (en-US)
    43. plugins (en-US)
    44. pointerLockElement
    45. Deprecated preferredStyleSheetSet (en-US)
    46. readyState
    47. referrer (en-US)
    48. Deprecated rootElement (en-US)
    49. scripts
    50. scrollingElement (en-US)
    51. Deprecated selectedStyleSheetSet (en-US)
    52. styleSheets
    53. Deprecated styleSheetSets (en-US)
    54. Experimental timeline (en-US)
    55. title (en-US)
    56. URL
    57. visibilityState (en-US)
    58. Deprecated vlinkColor (en-US)
    59. Deprecated width (en-US)
    60. Deprecated xmlEncoding (en-US)
    61. Deprecated xmlVersion (en-US)
  4. Métodos
    1. adoptNode()
    2. append() (en-US)
    3. caretPositionFromPoint() (en-US)
    4. Non-Standard caretRangeFromPoint() (en-US)
    5. Deprecated clear()
    6. close()
    7. createAttribute()
    8. createAttributeNS() (en-US)
    9. createCDATASection() (en-US)
    10. createComment() (en-US)
    11. createDocumentFragment()
    12. createElement()
    13. createElementNS()
    14. Deprecated createEntityReference() (en-US)
    15. createEvent()
    16. createExpression() (en-US)
    17. createNodeIterator() (en-US)
    18. createNSResolver() (en-US)
    19. createProcessingInstruction() (en-US)
    20. createRange()
    21. createTextNode()
    22. Deprecated createTouch() (en-US)
    23. Deprecated createTouchList() (en-US)
    24. createTreeWalker() (en-US)
    25. elementFromPoint() (en-US)
    26. elementsFromPoint() (en-US)
    27. Deprecated enableStyleSheetsForSet() (en-US)
    28. evaluate() (en-US)
    29. Deprecated execCommand()
    30. exitFullscreen()
    31. exitPictureInPicture() (en-US)
    32. Experimental exitPointerLock() (en-US)
    33. getAnimations() (en-US)
    34. getElementById()
    35. getElementsByClassName()
    36. getElementsByName()
    37. getElementsByTagName()
    38. getElementsByTagNameNS()
    39. getSelection()
    40. hasFocus()
    41. hasStorageAccess() (en-US)
    42. importNode()
    43. Non-Standard mozSetImageElement() (en-US)
    44. open()
    45. prepend() (en-US)
    46. Deprecated queryCommandEnabled() (en-US)
    47. Deprecated queryCommandSupported() (en-US)
    48. querySelector()
    49. querySelectorAll()
    50. Deprecated registerElement()
    51. releaseCapture() (en-US)
    52. replaceChildren() (en-US)
    53. requestStorageAccess() (en-US)
    54. write()
    55. writeln()
  5. Eventos
    1. Non-Standard afterscriptexecute (en-US)
    2. animationcancel (en-US)
    3. animationend (en-US)
    4. animationiteration (en-US)
    5. animationstart (en-US)
    6. Non-Standard beforescriptexecute (en-US)
    7. copy (en-US)
    8. cut (en-US)
    9. DOMContentLoaded (en-US)
    10. drag (en-US)
    11. dragend (en-US)
    12. dragenter (en-US)
    13. dragleave (en-US)
    14. dragover
    15. dragstart (en-US)
    16. drop (en-US)
    17. fullscreenchange (en-US)
    18. fullscreenerror (en-US)
    19. gotpointercapture (en-US)
    20. keydown
    21. Deprecated keypress (en-US)
    22. keyup
    23. lostpointercapture (en-US)
    24. paste (en-US)
    25. pointercancel (en-US)
    26. pointerdown (en-US)
    27. pointerenter (en-US)
    28. pointerleave (en-US)
    29. pointerlockchange
    30. pointerlockerror (en-US)
    31. pointermove (en-US)
    32. pointerout (en-US)
    33. pointerover (en-US)
    34. pointerup (en-US)
    35. readystatechange (en-US)
    36. scroll
    37. selectionchange (en-US)
    38. selectstart (en-US)
    39. touchcancel (en-US)
    40. touchend (en-US)
    41. touchmove (en-US)
    42. touchstart (en-US)
    43. transitioncancel (en-US)
    44. transitionend (en-US)
    45. transitionrun (en-US)
    46. transitionstart (en-US)
    47. visibilitychange (en-US)
    48. wheel (en-US)
  6. Herencia
    1. Node
    2. EventTarget

element.hasFocus

Resumen

El atributo hasFocus devuelve true si el foco está en en algún sitio del documento activo. Este atributo es parte de la especificación HTML 5 actualmente en desarrollo.

Sintaxis

focused = element.hasFocus

Ejemplo

Especificación

Focus management

Found a problem with this page?

  • Edit on GitHub
  • Source on GitHub
  • Report a problem with this content on GitHub
  • Want to fix the problem yourself? See our Contribution guide.

Last modified: 8 dic 2020, by MDN contributors

Your blueprint for a better internet.

  • MDN on Twitter
  • MDN on GitHub

MDN

  • About
  • Hacks Blog
  • Careers

Support

  • Product help
  • Report a page issue
  • Report a site issue

Our communities

  • MDN Community
  • MDN Forum
  • MDN Chat

Developers

  • Web Technologies
  • Learn Web Development
  • MDN Plus
  • Website Privacy Notice
  • Cookies
  • Legal
  • Community Participation Guidelines

Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2022 by individual mozilla.org contributors. Content available under a Creative Commons license.