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 Extensions
Developing extensions for web browsers
Accessibility
Build web projects usable for all
Web Technology
Web technology reference for developers
Filter sidebar
In this articleElement
ariaActiveDescendantElement
ariaAtomic
ariaAutoComplete
ariaBrailleLabel
ariaBrailleRoleDescription
ariaBusy
ariaChecked
ariaColCount
ariaColIndex
ariaColIndexText
ariaColSpan
ariaControlsElements
ariaCurrent
ariaDescribedByElements
ariaDescription
ariaDetailsElements
ariaDisabled
ariaErrorMessageElements
ariaExpanded
ariaFlowToElements
ariaHasPopup
ariaHidden
ariaInvalid
ariaKeyShortcuts
ariaLabel
ariaLabelledByElements
ariaLevel
ariaLive
ariaModal
ariaMultiLine
ariaMultiSelectable
ariaOrientation
ariaOwnsElements
ariaPlaceholder
ariaPosInSet
ariaPressed
ariaReadOnly
ariaRelevant
Non-standardariaRequired
ariaRoleDescription
ariaRowCount
ariaRowIndex
ariaRowIndexText
ariaRowSpan
ariaSelected
ariaSetSize
ariaSort
ariaValueMax
ariaValueMin
ariaValueNow
ariaValueText
assignedSlot
attributes
childElementCount
children
classList
className
clientHeight
clientLeft
clientTop
clientWidth
currentCSSZoom
elementTiming
ExperimentalfirstElementChild
id
innerHTML
lastElementChild
localName
namespaceURI
nextElementSibling
outerHTML
part
prefix
previousElementSibling
role
scrollHeight
scrollLeft
scrollLeftMax
Non-standardscrollTop
scrollTopMax
Non-standardscrollWidth
shadowRoot
slot
tagName
after()
animate()
append()
attachShadow()
before()
checkVisibility()
closest()
computedStyleMap()
getAnimations()
getAttribute()
getAttributeNames()
getAttributeNode()
getAttributeNodeNS()
getAttributeNS()
getBoundingClientRect()
getClientRects()
getElementsByClassName()
getElementsByTagName()
getElementsByTagNameNS()
getHTML()
hasAttribute()
hasAttributeNS()
hasAttributes()
hasPointerCapture()
insertAdjacentElement()
insertAdjacentHTML()
insertAdjacentText()
matches()
moveBefore()
Experimentalprepend()
querySelector()
querySelectorAll()
releasePointerCapture()
remove()
removeAttribute()
removeAttributeNode()
removeAttributeNS()
replaceChildren()
replaceWith()
requestFullscreen()
requestPointerLock()
scroll()
scrollBy()
scrollIntoView()
scrollIntoViewIfNeeded()
Non-standardscrollTo()
setAttribute()
setAttributeNode()
setAttributeNodeNS()
setAttributeNS()
setCapture()
Non-standard DeprecatedsetHTML()
ExperimentalsetHTMLUnsafe()
setPointerCapture()
toggleAttribute()
afterscriptexecute
Non-standard Deprecatedanimationcancel
animationend
animationiteration
animationstart
auxclick
beforeinput
beforematch
beforescriptexecute
Non-standard Deprecatedbeforexrselect
Experimentalblur
click
compositionend
compositionstart
compositionupdate
contentvisibilityautostatechange
contextmenu
copy
cut
dblclick
DOMActivate
DeprecatedDOMMouseScroll
Non-standard Deprecatedfocus
focusin
focusout
fullscreenchange
fullscreenerror
gesturechange
Non-standardgestureend
Non-standardgesturestart
Non-standardgotpointercapture
input
keydown
keypress
Deprecatedkeyup
lostpointercapture
mousedown
mouseenter
mouseleave
mousemove
mouseout
mouseover
mouseup
mousewheel
Non-standard DeprecatedMozMousePixelScroll
Non-standard Deprecatedpaste
pointercancel
pointerdown
pointerenter
pointerleave
pointermove
pointerout
pointerover
pointerrawupdate
pointerup
scroll
scrollend
scrollsnapchange
Experimentalscrollsnapchanging
Experimentalsecuritypolicyviolation
touchcancel
touchend
touchmove
touchstart
transitioncancel
transitionend
transitionrun
transitionstart
webkitmouseforcechanged
Non-standardwebkitmouseforcedown
Non-standardwebkitmouseforceup
Non-standardwebkitmouseforcewillbegin
Non-standardwheel
AbortController
AbortSignal
AbstractRange
Attr
CDATASection
CharacterData
Comment
CustomEvent
DOMError
DeprecatedDOMException
DOMImplementation
DOMParser
DOMPoint
DOMPointReadOnly
DOMRect
DOMTokenList
Document
DocumentFragment
DocumentType
Event
EventTarget
HTMLCollection
MutationObserver
MutationRecord
NamedNodeMap
Node
NodeIterator
NodeList
ProcessingInstruction
Range
StaticRange
Text
TextDecoder
TextEncoder
TimeRanges
TreeWalker
XMLDocument
Baseline Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since July 2015.
The hasAttributes()
method of the Element
interface returns a boolean value indicating whether the current element has any attributes or not.
js
hasAttributes()
Parameters
None.
Return valueA boolean.
Examplesjs
let foo = document.getElementById("foo");
if (foo.hasAttributes()) {
// Do something with 'foo.attributes'
}
Specifications Specification DOM Element.attributes
Element.hasAttribute()
Element.getAttribute()
Element.setAttribute()
Element.removeAttribute()
Element.toggleAttribute()
.
This page was last modified on Feb 15, 2024 by MDN contributors.
View this page on GitHubâ¢
Report a problem with this contentRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4