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