Differences browser jQuery.val ()
Statement
With jquery, if you have a button element defined as follows:<button value="123">456</button>
Browsers will give you different values if you use either .attr('value');, or.val();
Cause?
The item is
<button>simply <input type="button">in abbreviated form.How did you set the value <input type="button">, you need to setvalue="Click Me"
Consequently, <input type="button" value="Click Me">coincides with <button>Click Me</button>.
Question
Why use
.val()returns different values in different browsers. Who is right? Firefox:.val () = 123 | display text = 456
Chrome:
.val () = 123 | display text = 456
> = Internet Explorer 8:
.val () = 123 | display text = 456
<= Internet Explorer 7:
.val () = 456 | display text = 456
Reading specification w3 I am convinced that Chrome and Firefox are correct. In particular, because of this, this snippet:
, BUTTON INPUT, : BUTTON .
W3 , <button></button> , , . , Internet Explorer , , , Internet Explorer .
Safari 5, Opera, Chrome Firefox 3.6.8 Mac. 456 123 .val()