The 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();
The reason?
A
<button> element is simply <input type="button"> in a shorthand.
The way you would set the value of <input type="button"> is to set value="Click Me"
Hence <input type="button" value="Click Me"> is the same as <button>Click Me</button>.
The Question
Why does using
.val() return different values on different browser. Who is correct?Firefox:
.val() = 123 | displayed text = 456
Chrome:
.val() = 123 | displayed text = 456
>= Internet Explorer 8:
.val() = 123 | displayed text = 456
<= Internet Explorer 7:
.val() = 456 | displayed text = 456