Question: I have a an input field `<input value="hello"/>`. How do I get what is in the value attribute in a cross-browser way? If I do `$input.attr('value')` or `$input.val()`, it returns the current value that the user has typed into the field, rather than the value that is set in the value attribute.

If I do `input.getAttribute('value')`, it returns what I want, but is that cross-browser compatible?

Answer: 
Use the [`defaultValue`](http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26091157) property:

```
input.defaultValue;

$("whatever").get(0).defaultValue;

```
Using jquery, you would use:

```
$('input').attr('value');

```

But the getAttribute() function should be cross browser compatible.