mardi 20 octobre 2015

Typescript how to tell that element is checkbox, so element.checked is not red underlined

I am checking for input type of some element, fe checkbox in TS. Now I am sure that I have element that is checkbox, so this element should have property checked. But if I simply do

element: HTMLElement
if (element.InputType.toLowerCase() == "checkbox"){
    element.checked = true;
}

than it is working, but element.checked is red underlined. I think that I simply have to retype from HTMLElement to something like CheckboxElement, but did not find anything suitable for this conversion. How to get rid of this ? I have facing this also in case of element.value




Aucun commentaire:

Enregistrer un commentaire