<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
body{
margin: 0;
}
.c1{
top: 10px;
left: 10px;
position: relative;
width: 150px;
height: 22px;
border: 1px solid black;
padding-right: -22px;
}
.c2{
position: absolute;
width: 22px;
height: 22px; line-height: 22px;
text-align: center;
background-color: #dce7f4;
border-right: 1px solid black;
cursor: pointer;
}
.c3{ }
.c3 input{
border: 0;
padding: 0;
position: absolute;
left: 23px;
width: 104px;
height: 22px;
line-height: 22px;
text-align: center; } .c4{
right: 0;
position: absolute;
width: 22px;
height: 22px;
line-height: 22px;
text-align: center;
border-left: 1px solid black;
background-color: #dce7f4;
cursor: pointer;
} </style>
</head>
<body>
<div class="c1">
<div class="c2" onclick="Minus()">-</div> <div class="c3">
<input type="text" id="count" value="0" />
</div> <div class="c4" onclick="Plus()">+</div>
</div>
<script type="text/javascript">
//定义函数
function Plus() {
var old_str = document.getElementById('count').value;
try{
var old_int = parseInt(old_str);
}catch(e){
var old_int = 1
}
var new_int = old_int + 1;
document.getElementById('count').value = new_int;
}
function Minus() {
var old_str = document.getElementById('count').value;
try{
var old_int = parseInt(old_str);
}catch(e){
var old_int = 1
}
var new_int = old_int - 1;
document.getElementById('count').value = new_int;
}
</script>
</body>
</html>

加减 script函数初识的更多相关文章

  1. 用python进行月份加减的函数

    import math def add_month(datamonth, num): """ 月份加减函数,返回字符串类型 :param datamonth: 时间(20 ...

  2. mysql加减时间-函数-时间加减

    select timediff('23:40:00', ' 18:30:00'); -- 两时间相减 SELECT substring( timediff(,) ----“:”相减返回小时:分钟 -- ...

  3. Delphi日期函数、日期加减

    Delphi里有现成的函数可以实现日期加减,是在DateUtils单元里的. function IncYear(const AValue: TDateTime; const ANumberOfYear ...

  4. 【python】详解time模块功能asctime、localtime、mktime、sleep、strptime、strftime、time等函数以及时间的加减运算

    在Python中,与时间处理相关的模块有:time.datetime以及calendar.学会计算时间,对程序的调优非常重要,可以在程序中狂打时间戳,来具体判断程序中哪一块耗时最多,从而找到程序调优的 ...

  5. DB2时间函数 实现 时间加减

    时间加减:后边记得跟上时间类型如day.HOUR TIMESTAMP ( TIMESTAMP(DEF_TIME)+1 day)+18 HOUR   DB2时间函数是我们最常见的函数之一,下面就为您介绍 ...

  6. 小巧实用的数字加减插件(jquery插件)

    2015-12-04 近期项目需要,我将插件更新了,增加了两个参数,一个参数控制文本框是否支持输入,另一个参数则是新增了一个回调函数,返回文本框内的值.另外对代码局部重构了,优化了一下封装,需要的朋友 ...

  7. js实现购买数量加减效果

    写在前面:当我们需要在多个页面都有操作数量的需求时的一种解决方案 结构: js代码: <script type="text/javascript"> function ...

  8. js jquery 权限单选 bug修改以及正确代码 购物车数量加减

    效果图废话不多直接上代码 用的avalon渲染,其实都是一样的 <div class="shop-arithmetic"> <a href="javas ...

  9. php生成动态验证码 加减算法验证码 简单验证码

    预览效果: <?php /** *ImageCode 生成包含验证码的GIF图片的函数 *@param $string 字符串 *@param $width 宽度 *@param $height ...

随机推荐

  1. sql获取数组指定元素

    需求:获取字符数组1,2,3的第2个元素 方法:通过自定义函数来实现 /* 获取字符串数组某个元素 */ from sysobjects where id = object_id('Get_StrAr ...

  2. 请简单介绍一下Spring

    Spring 是一个开源框架,是为了解决企业应用程序开发复杂性而创建的.框架的主要优势之一就是其分层架构,分层架构允许您选择使用哪一个组件,同时为 J2EE 应用程序开发提供集成的框架. Spring ...

  3. 【leetcode刷题笔记】Sort List

    Sort a linked list in O(n log n) time using constant space complexity. 题解:实现一个链表的归并排序即可.主要分为三部分: 1.找 ...

  4. 【leetcode刷题笔记】Binary Tree Preorder Traversal

    Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tr ...

  5. 导出数据到表格PHP

    导出数据到表格 public function excel(){ $filename = '导出表格'; $header = ['编号','名称']; $index = ['id','name']; ...

  6. ImportError: no module named win32api

    ImportError: no module named win32api 安装win32包就好了 pip install pypiwin32

  7. FastReport5的安装

    1.运行recompile.exe,选择相应的delphi版本,选择recompile to chinese,编译: 2.选择recompile all pakages,编译: 3.将lib目录下的d ...

  8. Java -- 乒乓球 乒乓弹球游戏

    <疯狂Java讲义> 练习游戏 import java.awt.Canvas; import java.awt.Color; import java.awt.Dimension; impo ...

  9. Linux- 运维

    Linux运维遇到需要使用命令 查看Linux系统有多少用户 cat /etc/passwd | wc -l 查看用户占用的uid,默认情况下,ldap新增的用户和系统本地的用户uid是混在一起.在新 ...

  10. spring boot: scope (一般注入说明(一) @Autowired注解)

    实例一: DiConfig 文件: package di; import org.springframework.context.annotation.ComponentScan; import or ...