HTML: Input type button - value equivalent to defaultValue

ritaidmdett

New Member
I need to change the value of an input with type="button". Another function checks if it's value has been changed by comparing the "value" attribute with the "defaultValue" attribute (but that's beside the point...). This works fine for everything else except for inputs with type="button". For some reason the browser changes the default value too. But why?Note: No jQuery!Here's a simplified test code:\[code\]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <script type="text/javascript"> function d(input) { alert("value: "+ input.value +"\ndefaultValue: "+ input.defaultValue); } </script><body> <input type="button" value="http://stackoverflow.com/questions/15601499/0" onclick="d(this); this.value=http://stackoverflow.com/questions/15601499/1; d(this);" /></body></html>\[/code\]
 
Back
Top