input type = button 的onclick属性调用函数


调用js函数

<!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>

JQuery调用

<!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">    //无onclick,隐含调用
</body>
</html>

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM