From 074785cea106179cb3305637055ab0a009ca74f2 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:52 -0500 Subject: initial commit --- .../web/api/document/getelementsbyname/index.html | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 files/ru/web/api/document/getelementsbyname/index.html (limited to 'files/ru/web/api/document/getelementsbyname/index.html') diff --git a/files/ru/web/api/document/getelementsbyname/index.html b/files/ru/web/api/document/getelementsbyname/index.html new file mode 100644 index 0000000000..73b8921d61 --- /dev/null +++ b/files/ru/web/api/document/getelementsbyname/index.html @@ -0,0 +1,90 @@ +--- +title: Document.getElementsByName() +slug: Web/API/Document/getElementsByName +translation_of: Web/API/Document/getElementsByName +--- +
{{APIRef("DOM")}}
+ +

Метод getElementsByName()  объекта {{domxref("Document")}} возвращает коллекцию {{domxref("NodeList")}} элементов с заданным  {{domxref("element.name","name")}}.

+ +

Синтаксис

+ +
var elements = document.getElementsByName(name);
+
+ + + +

Пример

+ +
<!DOCTYPE html>
+<html lang="en">
+<title>Example: using document.getElementsByName</title>
+
+<input type="hidden" name="up">
+<input type="hidden" name="down">
+
+<script>
+  var up_names = document.getElementsByName("up");
+  console.log(up_names[0].tagName); // displays "INPUT"
+</script>
+</html>
+
+ +

Notes

+ +

The {{domxref("element.name","name")}} attribute can only be applied in (X)HTML documents.

+ +

The returned {{domxref("NodeList")}} Collection contains all elements with the given name, such as {{htmlelement("meta")}}, {{htmlelement("object")}}, and even elements which do not support the name attribute at all.

+ +
+

The getElementsByName method works differently in IE10 and below. There, getElementsByName() also returns elements that have an id attribute with the specified value. Be careful not to use the same string as both a name and an id.

+
+ +
+

The getElementsByName method works differently in IE. There, getElementsByName() does not return all elements which may not have a name attribute (such as <span>).

+
+ +
+

Both IE and Edge return an {{domxref("HTMLCollection")}}, not a {{domxref("NodeList")}}

+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-document-getelementsbyname', "Document.getElementsByName()")}}{{ Spec2('HTML WHATWG') }} 
{{SpecName("DOM2 HTML", "html.html#ID-71555259", "Document.getElementsByName()")}}{{Spec2("DOM2 HTML")}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.Document.getElementsByName")}}

+ +

See also

+ + -- cgit v1.2.3-54-g00ecf