keyboard
02-20-2012, 10:13 AM
Can anyone tell me why this won't work?
<html>
<head>
<script type="text/javascript">
function $(element) {
return document.getElementById(element);
}
function bob() {
var x = $('text1');
alert(x);
}
</script>
</head>
<body>
<a href="#" onclick="bob()">Hello</a>
<input type="text" value="54321" id="text1">
</body>
</html>
<html>
<head>
<script type="text/javascript">
function $(element) {
return document.getElementById(element);
}
function bob() {
var x = $('text1');
alert(x);
}
</script>
</head>
<body>
<a href="#" onclick="bob()">Hello</a>
<input type="text" value="54321" id="text1">
</body>
</html>