var data={ "total": 1, "page": 1, "records": 8, "costtime": "196.0112", "rows": [{ "Row": 1, "id": 38, "title": "adsf", "keyword": "asdf", "description": "", "realTitle": "", "imgSrc": "/goodimage/20170329163544563_01-1.jpg", "fileSrc": "", "createTime": "2017-03-29T16:03:10", "updateTime": "2017-03-29T16:35:46", "editor": "管理員", "source": "本站", "sort": 1, "hits": 0, "content": "sadf", "typeId": 19, "fine": false, "view": true, "role": 1, "url": "/admin/Net/Https/02_article.ashx", "a1": "", "a2": "", "a3": "", "a4": "", "a5": "", "a6": "", "a8": "", "a7": "", "a10": "", "a9": "", "typeIds": "我的產(chǎn)品", "expanded": "true", "isLeaf": "false", "rgt": "9999999", "lft": "1" }]};$.each(data.rows,function(index,row){ console.log("第"+row.Row+"行"); $.each(row,function(k,v){ console.log(k + "=" + v); });});
創(chuàng)新互聯(lián)成立于2013年,我們提供高端重慶網(wǎng)站建設(shè)公司、成都網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、網(wǎng)站定制、網(wǎng)絡(luò)營(yíng)銷推廣、微信小程序開發(fā)、微信公眾號(hào)開發(fā)、成都網(wǎng)站營(yíng)銷服務(wù),提供專業(yè)營(yíng)銷思路、內(nèi)容策劃、視覺設(shè)計(jì)、程序開發(fā)來(lái)完成項(xiàng)目落地,為工商代辦企業(yè)提供源源不斷的流量和訂單咨詢。
var begintime_ms = Date.parse(new Date(begintime.replace(/-/g, "/"))); //begintime 為開始時(shí)間
var endtime_ms = Date.parse(new Date(endtime.replace(/-/g, "/"))); // endtime 為結(jié)束時(shí)間
得到的結(jié)果為 毫秒數(shù),可根據(jù) 毫秒數(shù)的大小,來(lái)判斷時(shí)間。
當(dāng)然根據(jù)毫秒數(shù) 可以根據(jù)他們的差值 來(lái)求相差的天數(shù)或是小時(shí)等。
-------------------------------
以上是求得 用戶輸入時(shí)間的毫秒數(shù)
var date1=new Date(); //開始時(shí)間
var date2=new Date(); //結(jié)束時(shí)間
var date3=date2.getTime()-date1.getTime() //時(shí)間差的毫秒數(shù)
jquery根據(jù)出生年月計(jì)算年齡的思路:
1、創(chuàng)建當(dāng)前日期對(duì)象
2、把出生年月日格式化成可比較的格式
3、用當(dāng)前日期減去出生年月日計(jì)算出的日除以365就是年齡數(shù)
舉例說(shuō)明:
function getAge(dateString)
{
var today = new Date(); //創(chuàng)建系統(tǒng)日期
var birthDate = new Date(dateString); //把出生日期轉(zhuǎn)換成日期
var age = today.getFullYear() - birthDate.getFullYear(); //分別獲取到年份后相減
var m = today.getMonth() - birthDate.getMonth();//獲取到月份后相減
if (m 0 || (m === 0 today.getDate() birthDate.getDate()))
{
? ?age--;//如果月份的結(jié)果小于等于0,或者日期相減的結(jié)果是0,年齡減去1
}
return age; //計(jì)算完成返回結(jié)果
}?
調(diào)用測(cè)試結(jié)果如下:
jquery部分
function?testAdd(){????????
var?aa=$("#aa");????????
var?bb=$("#bb");
a=parseInt(aa.val());
b=parseInt(bb.val());
b=b+a;
bb.val(b);
bb.innerHTML=bb.value;
}????
function?testSub(){????????
var?aa=$("#aa");????????
var?bb=$("#bb");
a=parseInt(aa.val());
b=parseInt(bb.val());
b=b-a;
bb.value=b;
bb.innerHTML=bb.value;
}
html部分
body????
input?type="button"?name="add"?value="add"?onclick="testAdd()"????
input?type="text"?id="aa"????
input?type="button"?name="sub"?value="sub"?onclick="testSub()"????
br/????
購(gòu)物車????
input?type="text"?value="100"?id="bb"
/body
body
總和:input?type="text"?id="total"?readonly="readonly"?/
table?id="panel"
tr
td面積:/td
tdinput?id="area"?type="text"?class="price"?value="16.2"http://td
td*(數(shù)量:/td
tdinput?id="num"?type="text"?class="num"?//td
td+價(jià)格:/td
tdinput?id="price"?type="text"?class="numm"?//td
td+重量:/td
tdinput?id="weight"?type="text"?class="numm"/)/td
/tr
/table
/body
------jQuery
$(function(){
var?area=parseFloat($("#area").val());
var?num=parseInt($("#num").val());
var?price=parseFloat($("#price").val());
var?weight=parseFloat($("#weight").val());
var?total=area*(num+price+weight)
$("#total").val(total);
});
實(shí)現(xiàn)代碼:
$(document).ready(function(){
run(enddate);
});
//定時(shí)器
function?run(enddate){
//如果enddate為后臺(tái)傳入的Date類型,這里直接轉(zhuǎn)化為毫秒數(shù)
enddate=new?Date(eddate.replace("T","?").getTime());
//以500毫秒的速度執(zhí)行(可以避免方法執(zhí)行速度慢會(huì)影響展示效果的情況)0
var?time?=?500;?
setInterval("dateDif('"+enddate+"')",time);
}
//計(jì)算時(shí)間相差
function?dateDif(enddate){
var?date?=?enddate?-?new?Date().getTime();?
var?days????=?date?/?1000?/?60?/?60?/?24;
var?daysRound???=?Math.floor(days);
var?hours????=?date/?1000?/?60?/?60?-?(24?*?daysRound);
var?hoursRound???=?Math.floor(hours);
var?minutes???=?date?/?1000?/60?-?(24?*?60?*?daysRound)?-?(60?*?hoursRound);
var?minutesRound??=?Math.floor(minutes);
var?seconds???=?date/?1000?-?(24?*?60?*?60?*?daysRound)?-?(60?*?60?*?hoursRound)?-?(60?*?minutesRound);
var?secondsRound??=?Math.floor(seconds);
var?time?=?"倒計(jì)時(shí)"+(daysRound+"天"+hoursRound?+"時(shí)"+minutesRound+"分"+secondsRound+"秒");
$("#ytime").text(time);
}