Element.value 和 Element.getAttribute("value") 的区别 [英] Difference between Element.value and Element.getAttribute("value")

查看:28
本文介绍了Element.value 和 Element.getAttribute("value") 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道两者之间有什么区别.我注意到这两种方法有时会产生不同的结果.

I'm just wondering what the difference is between the two. I have noticed the two methods give different results at times.

推荐答案

区别在于 element.value 是实时的,如果用户更改例如文本框输入,它将反映,并向您展示新值.

The difference is that element.value is real time and if a user changes let's say, a textbox input, it will reflect that, and show you the new value.

虽然 getAttribute('value') 仍会显示原始的 value="whateverWasHere" 值.

While getAttribute('value') will still show the original value="whateverWasHere" value.

jsFiddle 演示

这篇关于Element.value 和 Element.getAttribute("value") 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆