Giúp em cái này với.

e mới học javascript, học đến bài này thì ko biết sai ở chổ nào,trình duyệt thông báo "Uncaught ReferenceError: hello is not defined" ở dòng
Mã:
<input type="button" onclick="hello();" value="submit"/>
nhờ mấy pro giúp e với ạ
Mã:
<html><head>
<script type="text/javascipt">
    function hello() {
    var nhapten = document.getElementById('yourname').value;
    alert(nhapten);
    }
</script>
</head>
<body>
<input type="text" name="yourname" id="yourname" />
<input type="button" onclick="hello();" value="submit"/>
</body>
</html>
 
Lỗi xảy ra ở từ "javascipt", bạn đánh sai từ rồi. Dưới đây là code chạy ok. Thanks

<html>
<head>
<script type="text/javascript">
function hello() {
var nhapten = document.getElementById('yourname').value;
alert(nhapten);
}
</script>
</head>
<body>
<input type="text" name="yourname" id="yourname" />
<input type="button" onclick="hello();" value="submit" />
</body>
</html>
 

Thống kê

Chủ đề
100,667
Bài viết
467,441
Thành viên
339,833
Thành viên mới nhất
duythinh2222
Top