10 examples of 'getelementbytagname' in JavaScript

Every line of 'getelementbytagname' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
1094function getElementByTagName(tagName) {
1095
1096 return document.getElementsByTagName(tagName)[0];
1097}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

328function getElementByTagName( tagName ) {
329
330 return document.getElementsByTagName( tagName )[ 0 ];
331
332}
68function getElementByName(element, name) {
69 var parent = element.parentNode;
70
71 while (parent.className !== "present") {
72 parent = parent.parentNode;
73 }
74
75 return findChild(parent, name);
76}
16export function getElement(el: FinderResult): ElementFinder {
17 return typeof el === 'string' ? element(by.css(el)) : el;
18}
79function byTagName(tag, context) {
80 var elem,
81 tmp = [],
82 i = 0,
83 results = context.getElementsByTagName(tag);
84 if (tag === "*") {
85 while ((elem = results[i++])) {
86 if (elem.nodeType === 1) {
87 tmp.push(elem);
88 }
89 }
90 return tmp;
91 }
92 return results;
93};
119function findClosestAncestor(element: Element | null, tagName: string) {
120 return !element
121 ? null
122 : element.tagName === tagName
123 ? element
124 : findClosestAncestor(element.parentElement, tagName);
125}
33public getTagName(element: Element): string {
34 return element.tagName.toLowerCase();
35}
188function findElementsWithTagName(root, tagName) {
189 return (
190 root.tagName == tagName
191 ? [root]
192 : []
193 ).concat(
194 typeof root.getElementsByTagName == "function"
195 ? slice.call(root.getElementsByTagName(tagName))
196 : []
197 )
198}
323getElementTagName(handle) {
324 const webElement = handle.getElement();
325 return webElement.getTagName();
326}
20function find_tag_in_parents (tag, element) {
21 // FIXME If tag names will always be upper-case, toLowerCase() can
22 // be eliminated. Also not sure that p will ever be null.
23 tag = tag.toLowerCase();
24 for (let p = element.parentNode;
25 p != null && p.tagName.toLowerCase() != "html";
26 p = p.parentNode)
27 {
28 if (p.tagName.toLowerCase() == tag)
29 return p;
30 }
31 return null;
32}

Related snippets