Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

JS | getElementsByName

Empfohlene Antworten

Veröffentlicht

Hi Leute,

ich verwende folgenden Code:

mein jscript: (tools.js)


function getElement( e){


   var el = document.getElementById( e);


   if ( el == null) {

      el = document.getElementsByName( e)[0];

   }


   // Array von gleichnamigen Elementen heraussuchen

   if ( getElement.arguments.length > 1 && getElement.arguments[1] == "getElementsArray") {

      el = document.getElementsByName( e);

   }


   if ( el != null) {

      return el;

   }


   return null;

}


mein html:

<html>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

   <title>k!cked - online gaming since 2003</title>

   <link rel="stylesheet" href="main.css" type="text/css">

<script src="tools.js" type="text/javascript">

            </script></head>

<body>

<table>

<tr name="row">

<td>

</td>

</tr>

<tr name="row">

<td>

</td>

</tr>

<tr name="row">

<td>

</td>

</tr>

</table>


<span onClick="alert(getElements('row', 'getElementsArray'));">get Elements</span>

<span onClick="alert(getElements('row', 'getElementsArray')[0]);">get Element 1</span>

<span onClick="alert(getElements('row', 'getElementsArray')[1]);">get Element 2</span>


</body>

</html>

ausgaben:

get Elements: Object

get Elements 1: Undefined

get Elements 2: Undefined

es sollte doch normalerweise so aussehen:

get Elements: Array

get Elements 1: Object

get Elements 2: Object

was mache ich falsch?

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.