Antwort an „Gunnar Bittersmann“ verfassen

@@Matthias Scharwies

	const topLink = document.getElementById('skip-to-top');
	const nav = document.querySelector('nav');

Warum document.getElementById()? Warum nicht einheitlich document.querySelector()?


			if (!entry.isIntersecting) {
				topLink.style.display = 'block';
			} else {
				topLink.style.display = 'none';
			}

Besser:

			topLink.style.display = !entry.isIntersecting ? 'block' : 'none';

oder andersrum

			topLink.style.display = entry.isIntersecting ? 'none' : 'block';

Noch besser:

			topLink.hidden = entry.isIntersecting;

mit <a href="#willkommen" id="skip-to-top" hidden>skip to top</a> im Markup.

Wie oft muss man das hidden-Attribut und seine Vorteile noch erwähnen, bis es Beachtung findet?

Kwakoni Yiquan

--
Ad astra per aspera
freiwillig, öffentlich sichtbar
freiwillig, öffentlich sichtbar
freiwillig, öffentlich sichtbar

Ihre Identität in einem Cookie zu speichern erlaubt es Ihnen, Ihre Beiträge zu editieren. Außerdem müssen Sie dann bei neuen Beiträgen nicht mehr die Felder Name, E-Mail und Homepage ausfüllen.

abbrechen