Ich habe eine Element
, und ich kann nicht herausfinden, wie man die HTMLElement
daraus bekommen.Get HTMLElement von Element
Zum Beispiel:
<a href="">A link</a>
<a href="">Another link</a>
ich sie dann etwa so:
var nodes: NodeListOf<Element> = document.querySelectorAll('a'); // Returns a NodeList of Elements
for (let i = 0; i < nodes.length; i++) {
var node = nodes.item(i);
// How can I get the HTMLElement here?
}
bearbeiten
Hier ist der Code:
let nodes: NodeListOf<Element> = document.querySelectorAll('a');
for (let i = 0; nodes[i]; i++) {
let node = nodes[i];
var c = nodes[i].style.backgroundColor = 'red';
}
müssen Sie eine Art Assertion https://basarat.gitbooks.io/typescript/content/docs/types/type-assertion.html – basarat