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

HTML simple shopping quantity applet

高洛峰
Release: 2017-02-18 15:43:03
Original
1985 people have browsed it

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>
Copy after login

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!


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template