jeudi 18 octobre 2018

Why don't comparison an element.getElementsByTagName('ol') in the "if"?

I did trying comparison "getElementsByTagName('ol')" at the "if". But, don't comparison it. This situation such as below example.

 var article = document.getElementById('article');
            if (article) {
                if (article.getElementsByTagName('ole')) {
                    return console.log(true);
                }
            }

Of above, I don't have "" tag. But it's returned value "true". If it is as normally situation, returned value "false".

But, proceed to as normally, if written to "article.getElementsByTagName('ole').length".

In conclusion, why don't checked value boolean by "getElementsByTagName('ole')"?




Aucun commentaire:

Enregistrer un commentaire