问答详情
源自:5-1 什么是函数

怎么才能实现点一下,弹出一下??

如题,and看图

提问者:无敌小哥儿 2016-03-15 23:28

个回答

  • dinshuhon
    2016-03-16 21:43:13
    已采纳

    上面的有点小错误:这个才是对的 

    <html>
        <head>
          <meta http-equiv="Content-Type" Content="text/html; charset=utf-8" />
    
            <script type="text/javascript">
                var a = 0;
                var b = 1;
                function app(){
                    var sum = ++a + ++b;   
                    alert(sum)
                }
        
            </script>
        </head>
        <body>
            <input name="button" type="button" onClick="app()" value="看我"/>
        </body>
    </html>


  • 慕慕4512663
    2017-05-29 14:29:19

    <!DOCTYPE html>
    <html>
    <head>
    	<meta charset="utf-8">
    	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    	<title></title>
    	<script type="text/javascript" charset="utf-8" async defer>
    	window.onload=function(){
    	var a=0;
    	var b=1;
           var add=document.getElementById('bt');
           add.onclick=function(){
           	sum=++a + ++b;
               alert(sum);
           }}
    	</script>
    </head>
    <body>
    	<input type="button" value="bt" id="bt">
    </body>
    </html>
    不知道这是不是你想要的效果

  • 慕慕4512663
    2017-05-29 14:21:19

    <!DOCTYPE html>

    <html>

    <head>

    <meta charset="utf-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <title></title>

    <script type="text/javascript" charset="utf-8" async defer>

    var a=0;

    var b=1;

    function ad(a,b){

    while(b<10) {

               sum=++a + ++b;

               alert(sum);}

           }

    </script>

    </head>

    <body>

    <input type="button" value="点击" onclick="ad(a,b)">

    </body>

    </html>


  • dinshuhon
    2016-03-16 21:41:34

    <html>
        <head>
          <meta http-equiv="Content-Type" Content="text/html; charset=utf-8" />
    
            <script type="text/javascript">
                var a = 0;
                var b = 1;
                function app(){
                    var sum = ++a + ++b;   
                    alert(sum)
                }
        
            </script>
        </head>
        <body>
            <input name="button" type="button" onClick="app(3,4)" value="看我"/>  
        </body>
    </html>


  • dinshuhon
    2016-03-16 00:04:48

    你是要哪一种效果  点一下弹出一下???

    <html>
        <head>
          <meta http-equiv="Content-Type" Content="text/html; charset=utf-8" />
    
            <script type="text/javascript">
                function app(a,b){
                    var sum=a+b;   
                    alert(sum)
                }
        
            </script>
        </head>
        <body>
            <input name="button" type="button" onClick="app(3,4)" value="看我"/>
        </body>
    </html>