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.

JavaScript Problem : DIV ein/ausblenden

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

ich habe ein kleines Problem.

Und zwar will ich ein DIV nach betätigen einer Checkbox anzeigen oder ebend ausblenden.

JavaScript:


<script type="text/javascript" language="JavaScript">

	function Pruefung(){

		if(document.forms[0].Testradio.checked == true){

		document.forms[0].getElementById('test').style.display = 'inline';

		}else if (document.forms[0].Testradio.checked == false){

                 document.forms[0].getElementById('test').style.display = 'none';

                 }

	}

</script>

HTML:

<input type='checkbox' name='Testradio' value='bla' onclick='Pruefung();'></input>

<div name='test' id='test' style="display:none;">

Text der nuch nach Prüfung angezeigt werden soll 

</div>

Allerdings zeigt der IE(8) mir eine Fehlermeldung an:

"Das Objekt unterstützt diese Eigenschaft oder Methode nicht", was ich dann allerdings sehr komisch finde, da man bei vielen TUT's im Web genau solche Beispiele sieht.

Währe Nett wenn mir jemand weiterhelfen könnte.

Mfg

Serear

  • Autor

Moin,

danke für die Antwort :)

Hatte ' anstatt " da stehen, da ich das später noch in PHP implementiere.

Kann es sein dass man DIV's generell über JavaScript keine CSS-Attribute zuweisen kann ? Habe das selbe problem wenn ich die Position über JS ändern will.

Mfg

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.