函数不能放在ready里
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
function fas(){
alert(1);
}
</script>
</head>
<body>
<input type="button" onclick = "fas()" value = "sdsdsd">
</body>
</html>
第二种$(“#test”).click(function(){alert(1);});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(function(){
$("#test").click(function(){
alert(1);
});
});
</script>
</head>
<body>
<input id = "test" type="button" value = "sdsdsd">
</body>
</html>
(function()是 (document).ready(function(){}的简写