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.

document.getElementByÃŒd vs. document.form1.feld1

Empfohlene Antworten

Ich habe ne Webseite mit recht vielen Elementen (ca. 2000).

Macht es von der Performance her einen Unterschied, ob ich ein Element mit JS so

document.getElementById("button1")
anspreche, oder so
document.forms["form1"].elements["button1"]
oder so
document.forms[2].elements[14]
oder so
document.form1.button1

?

hm so pauschal ist das schlecht zu sagen.

Ich würd sagen, bau dir nen testfalls mit ein paar Elementen ( 500-1000, kannst du ja per PHP oder einer anderen Script-Sprache generieren) und test einfach mal alle Verfahren aus

Wäre schön, wenn du deine Ergebnisse dann hier posten könntest, das würde mich auch interessieren.

so, habs getestet. auf ner seite mit 7000 elementen (3000 davon hatten eine ID) waren alle möglichkeiten so schnell, dass man sie kaum messen konnte.

überraschenderweise war möglichkeit 1 (0 ms) schneller als möglichkeit 2 (10 ms).

document.getElementById("button1")
document.forms["form1"].elements["button1"]
document.forms[2].elements[14]
document.form1.button1

hast du das auch mit mehreren Browsern getestet?

auf welchem System hast du diese Tests durchgeführt?

Test nur mit IE6.0 auf WinXP SP1

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Konto

Navigation

Suchen

Suchen

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.