Languages
[Edit]
PL

JavaScript - pobranie elementu o określonym id

3 points
Created by:
Aisha
418

W tym artykule przyjrzymy się, jak uzyskać element za pomocą identyfikatora w JavaScript. 

Możemy to osiągnąć korzystając z jednej z metod dostępnych domyślnie w JavaScript:

  • document.getElementById('element-id')
  • document.querySelector('#element-id')
  • document.querySelectorAll('#element-id')

Poniżej możemy zobaczyć uruchamialne przykłady każdej z tych metod.

1. document.getElementById:

Edit

2. document.querySelector:

Edit

3. document.querySelectorAll:

Edit

Uwaga:

document.querySelectorAll działa ze zduplikowanymi identyfikatorami, ale w praktyce nie należy ich używać.

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join