$(document).keypress(function (e) { // 回車鍵事件 if (e.which == 13) { $('input[type="button"]').click(); } });
var fullscreen = function () { elem = document.body; if (elem.webkitRequestFullScreen) { elem.webkitRequestFullScreen(); } else if (elem.mozRequestFullScreen) { elem.mozRequestFullScreen(); } else if (elem.requestFullScreen) { elem.requestFullscreen(); } else { //瀏覽器不支持全屏API或已被禁用 } }
$(".checkall").click(function () { $(".checklist").prop("checked", this.checked); });
<!--格式化字符串時間格式爲yyyy-mm-dd--> function formatDate(date) { let d = new Date(date), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; return [year, month, day].join('-'); }
$(document).ready(function () { $('input[type=radio][name=optionsRadios]').change(function () { if (this.value == 'invoice_type_com') { document.getElementById("invoice_type").value = 1300163160; } else if (this.value == 'invoice_type_pro') { document.getElementById("invoice_type").value = 1300173160; } }); });
$(function(){ $('#bef_product_price').bind('input propertychange', function() { cal_tax_price(); }); $('#product_num').bind('input propertychange', function() { cal_tax_price(); });
// 判斷對象的值與傳入值是否相等 function isObjectValueEqual(a, b) { if(typeof(a) != "object" && typeof(b) != "object"){ if(a == b){ return true; }else{ return false; } } var aProps = Object.getOwnPropertyNames(a); var bProps = Object.getOwnPropertyNames(b); if (aProps.length != bProps.length) { return false; } for (var i = 0; i < aProps.length; i++) { var propName = aProps[i]; if (a[propName] !== b[propName]) { return false; } } return true; }; // 獲取數組中對象的索引 function getIndexWithArr(_arr,_obj) { var len = _arr.length; for(var i = 0; i < len; i++) { if(isObjectValueEqual(_arr[i],_obj)) { return i; } } return -1; }; // 刪除數組中的對象 function removeObjWithArr(_arr,_obj) { var length = _arr.length; for(var i = 0; i < length; i++) { if(isObjectValueEqual(_arr[i],_obj)) { if(i == 0) { _arr.shift(); //刪除並返回數組的第一個元素 return; } else if(i == length-1) { _arr.pop(); //刪除並返回數組的最後一個元素 return; } else { _arr.splice(i,1); //刪除下標爲i的元素 return; } } } };