<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
为什么函数在被 JavaScript 调用changeText
时起作用,onclick="changeText('tare.e')"
但在 JavaScript 中调用时不起作用
function changeText(idname,newtext)
{
document.getElementById(idname).value = newtext;
}
changeText('tare.e','from javascript' );
// Calling here causes the error: `Unable to set value of the property 'value': object is null or undefined`
</script>
<input id="tare.e" value="text" >
<input id="tare.e_button" type="button" value="BUTTON" onclick=" changeText('tare.e','from button')"/>
</body>
</html>