From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/fr/web/api/element/hasattribute/index.html | 127 +++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 files/fr/web/api/element/hasattribute/index.html (limited to 'files/fr/web/api/element/hasattribute/index.html') diff --git a/files/fr/web/api/element/hasattribute/index.html b/files/fr/web/api/element/hasattribute/index.html new file mode 100644 index 0000000000..2f1ab2a913 --- /dev/null +++ b/files/fr/web/api/element/hasattribute/index.html @@ -0,0 +1,127 @@ +--- +title: element.hasAttribute +slug: Web/API/Element/hasAttribute +tags: + - API + - DOM + - Element + - Méthode + - Reference +translation_of: Web/API/Element/hasAttribute +--- +

{{APIRef("DOM")}}

+ +

La méthode Element.hasAttribute() renvoie une valeur booléenne indiquant si l'élément courant possède l'attribut spécifié ou non.

+ +

Syntaxe

+ +
var result = element.hasAttribute(name);
+
+ +
+
result
+
récupère la valeur de retour true ou false.
+
name
+
est une chaine de caractères représentant le nom de l'attribut.
+
+ +

Exemple

+ +
var foo = document.getElementById("foo");
+if (foo.hasAttribute("bar")) {
+    // faire quelque chose
+}
+ +

Polyfill

+ +
;(function(prototype) {
+    prototype.hasAttribute = prototype.hasAttribute || function(name) {
+        return !!(this.attributes[name] &&
+                  this.attributes[name].specified);
+    }
+})(Element.prototype);
+ +

Notes

+ +

{{DOMAttributeMethods}}

+ +

Spécification

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationStatutCommentaire
{{SpecName('DOM WHATWG', '#dom-element-hasattribute', 'Element.hasAttribute()')}}{{Spec2('DOM WHATWG')}}Dans {{SpecName('DOM3 Core')}}, déplacé de {{domxref("Node")}} à {{domxref("Element")}}
{{SpecName('DOM3 Core', 'core.html#ID-ElHasAttr', 'Element.hasAttribute()')}}{{Spec2('DOM3 Core')}}Pas de changement par rapport à {{SpecName('DOM2 Core')}}
{{SpecName('DOM2 Core', 'core.html#ID-ElHasAttr', 'Element.hasAttribute()')}}{{Spec2('DOM2 Core')}}Définition initiale.
+ +

Browser compatibility

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
FonctionnalitéChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}8.0{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FonctionnalitéAndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
-- cgit v1.2.3-54-g00ecf