元素在IE 8中始终为空

用户名

我有以下代码:

 if (document.querySelectorAll('[id$=":maindiv:usernametext::content"]')[0].value == null || document.querySelectorAll('[id$="maindiv:usernametext::content"]')[0].value.trim() == "") {
        console.log("maindiv:usernametext::content IS EMPTY !!!);
    }

在IE 8中,此元素始终表示该值为空,即使不是。在浏览器> IE 8以及Chrome和Firefox中运行时,它可以工作。为什么每次都返回null。我正在IE 8标准模式下运行。

更新

所以我只是console.log(document.querySelectorAll('[id$=":maindiv:usernametext::content"]')[‌​0].value)并且它正在返回值,但是这种情况不起作用?因此,似乎选择器正在获取值,但是如果有值,则此if语句在不应该执行时执行?该字段只是一个文本字段。

用户名

事实证明IE 8不支持修剪功能,因此我将其删除,并且可以正常工作!

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章