<!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. Sqoop架构以及应用介绍

    本篇文章在具体介绍Sqoop之前,先给大家用一个流程图介绍Hadoop业务的开发流程以及Sqoop在业务当中的实际地位.  如上图所示:在实际的业务当中,我们首先对原始数据集通过MapReduce进行 ...

  2. 【leetcode刷题笔记】Jump Game II

    Given an array of non-negative integers, you are initially positioned at the first index of the arra ...

  3. Linux电源管理(4)-Power Manager Interface【转】

    本文转载自:http://www.wowotech.net/pm_subsystem/pm_interface.html 1. 前言 Linux电源管理中,相当多的部分是在处理Hibernate.Su ...

  4. C#实现对外部程序的调用操作

    测试工具,首先也是一个C#的程序,它的主要目的是: 1:获取上文应用程序的窗口句柄,继而获取TextBox句柄及Button句柄: 2:为TextBox随机填入一些字符: 3:模拟点击Button: ...

  5. cdoj 1256 昊昊爱运动 预处理

    昊昊爱运动 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) 昊昊喜欢运动 他NN ...

  6. BZOJ 1965 [Ahoi2005]SHUFFLE 洗牌:快速幂 + 逆元

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1965 题意: 对于扑克牌的一次洗牌是这样定义的,将一叠N(N为偶数)张扑克牌平均分成上下两 ...

  7. javascript 数组 去重

    javascript数组去重有如下 方法: 一) 利用 数组中的 indexOf判断  例如: Array.prototype.unique=function(){ var n=[]; for(var ...

  8. maven 3.2.5 的安装及简单示例

    http://www.mvnrepository.com 一直没有使用maven,它的作用就不说了,这二天需要用到,发现网上都是以前的版本,所以,我一边配置,一边记录. 一 下载maven 现在很多I ...

  9. ES field store yes no 区别——可以设置为false,如果_source有的话

    store By default, field values are indexed to make them searchable, but they are not stored. This me ...

  10. 验证reg注册表的操作

    // wRegKeyclass wRegKey{ // Operationspublic: BOOL Create(HKEY hKeyParent, LPCTSTR lpszKeyName , LPT ...