Hi,
Was hat querySelector() für Vorteile?
Dieselbe Syntax wie im CSS, nicht mal mit
#
, mal ohne.Performance … abnimmt. Daher würde ich doch in Fällen, wo ich diese Vielseitigkeit nicht brauche, lieber bei getElementById() bleiben wollen.
Das wäre in dem Fall wohl Mikro-Optimierung, die sich kaum messbar bemerkbar machen dürfte. Da wäre einfacherem Code (einheitliche Selektor-Syntax) der Vorzug zu geben.
okay, das kann ich als Begründung für die Allgemeinheit gelten lassen; für mich selbst ist es nicht schwerwiegend genug. Da werde ich wohl auch weiterhin im (häufig vorkommenden) Spezialfall die spezialisierte Funktion/Methode nehmen.
So long,
Martin
--
Nothing travels faster than the speed of light with the possible exception of bad news, which obeys its own special laws.
- Douglas Adams, The Hitchhiker's Guide To The Galaxy
Nothing travels faster than the speed of light with the possible exception of bad news, which obeys its own special laws.
- Douglas Adams, The Hitchhiker's Guide To The Galaxy