value attribute in <input> tag #939

ColorFuzzy opened this Issue Mar 13, 2014 · 2 comments


None yet

2 participants


Put <input value=5 id="input"> in body and input a 10 in input field.
$("#input").attr("value") will return 10;
$("#input").attr("value", 20) will replace value=5 to value=20, but the input field will not change.

  1. I can't get the value attribute value.
  2. I can't set the input field value.

pure javascript:
document.getElementById("input").value will get(can set) input field value;
document.getElementById("input").g[s]etAttribute("value", 20) will get/set value attribute.


Use val to get and set input field values, see


I can use val() to get/set input field values and I can also use $("#input").attr("value", 20) to set the value attribute value, but how can I get the value attribute value? $("#input").attr("value") and $("#input").val() both return the same value in input field.
The main problem is $("#input").attr("value", 20) and $("#input").attr("value") take effect on different place, this would confuse people.

@mislav mislav closed this in #960 Jun 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment