IE 9-10下如果option元素没有定义value而在设置innerText时没有把两边的空白去掉,那么 取el.text,浏览器会进行trim, 并且伪造一个value值,此值会在刚才trim的结果两边添加了一些空白

        <script>
            window.onload = function(){
            var el = document.getElementById("aaa")
            alert("|"+ el.value +"|")// "| eeee |"
            alert(!!el.hasAttribute && el.hasAttribute("value"))//false
            alert("|"+ el.text +"|")//  "|eeee|"
            }

        </script>
   


        <select>
            <option >
                eeee

            </option>
        </select>

相关文章:

  • 2021-08-16
  • 2021-07-02
  • 2021-12-12
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 2021-04-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-24
  • 2021-11-26
  • 2021-08-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案