Home  >  Article  >  Web Front-end  >  HTML simple shopping quantity applet

HTML simple shopping quantity applet

高洛峰
高洛峰Original
2017-02-18 15:43:031912browse

The example of this article shares an HTML simple shopping quantity applet for your reference. The specific content is as follows

<html>  
   <head>  
  
      <title>购物数量小程序</title>  
  
    <script>  
      function sub()   
      {          
  
        var a = buy.ans.value;   
            //alert(a);   
            a = parseInt(a);               
        a--;               
            if(a<0)   
             a = 0;   
            buy.ans.value = a;   
      }   
          function add()   
      {   
        var a = buy.ans.value;   
            a = parseInt(a);   
        a++;   
            buy.ans.value = a;   
      }   
        </script>  
  
   </head>  
  
   <body>  
     <form name="buy">  
    购买数量<input type="button"  value="-" onclick="sub()">  
            <input type="text" name="ans" value="1">  
            <input type="button"  value="+" onclick="add()">  
  
     </form>  
    </body>  
</html>

The above is the entire content of this article. I hope it will be helpful to everyone. Learning is helpful, and I hope everyone will support the PHP Chinese website.

For more HTML simple shopping quantity applet related articles, please pay attention to the PHP Chinese website!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn