javascript 日常

   $('#code').bind('keypress', function (e) {   //绑定回车处理
        if (e.keyCode == 13) {
            console.log($("#code"));
        }
    });
            $.ajax({
                url: "@Url.Action("Data")",
                type: "Post",
            data: { },
            dataType: "json",
            success: function (data) {
                app.tableData = data.rows;
            },
            error: function (jqXHR, textStatus, errorThrown) {

            }
        });
<div id="line" style="display:none">@Model.line</div>
 JSON.parse($("#line").html())   
前台接收 LIST<CLASS>

(~~(number * 10 *10 ) )/ 10 /10 js  保留二位小数

 (obj* 1).toFixed(2) *1 银行家摄入

 Math.round(v*10*10 )/10/10   js                ().toExponential(10)-0 解决  .99999999999999问题

math.round(obj,2) c#

 <input onkeyup="this.value=this.value.replace(/D/g,'')" onafterpaste="this.value=this.value.replace(/D/g,'')">   限制输入数字 .也不行

 var pages=TotalRecord%pageSize==0?(TotalRecord/pageSize):(Math.floor(TotalRecord/pageSize)+1);   js页数计算 

var rows = $('#List').datagrid('getSelections');

var d='';
rows.forEach(function(item){d+=item.BARCODE + "','";});
d ="'"+ d.substring(0, d.length - 2); 选中 返回  '1','2'

var a=["2018/09/18 08:00:00","2018/07/18 08:00:00","2018/10/18 08:00:00"]
a.sort().reverse()[0] 日期最大值,排序
app.tabke.find(function (x) {  return x.HID == app.checked }).STATUS   一个值到数据去找他的对象 

$("#a").find("tr:not(:first)").each(function ()
{
console.log(this);  循环行

$(this).find("input[name='txt']").val()   获取当前行文本框

 $(this).find("td").eq(13)[0].innerHTML.trim() 获取行文本
})

$("#a").find("tr:last").clone();  最后 一行的副本 

$('#Settlement_Currency optin:selected').text() 获取选择下拉文本  

 $("#Settlement_Currency").find("option:selected").text()

 $("#Settlement_Currency").val()  获取选择下拉值

$("#Settlement_Currency").bind("input propertychange", function() {alert($(this).val());}); 下拉改变事件

 $("#dd").val(JSON.stringify(rows)); JSON.parse($("#dd").val())   JS 序列化和反序列化

时间戳转时间

value='/Date(123512530002)/

format(value.replace(/[^0-9]/ig, "") * 1)

function format(shijianchuo) {
//shijianchuo是整数,否则要parseInt转换
var time = new Date(shijianchuo);
var y = time.getFullYear();
var m = time.getMonth() + 1;
var d = time.getDate();
var h = time.getHours();
var mm = time.getMinutes();
return y.toString() + '-' + (m < 10 ? '0' + m : m).toString() + '-' + (d < 10 ? '0' + d : d).toString() + ' ' + (h < 10 ? '0' + h : h).toString() + ':' + (mm < 10 ? '0' + mm : mm).toString();
}

function ToDated( date)
{
if (date == null) {
return value;
}
var date = new Date(date.replace(/[^0-9]/ig, "") * 1);
return date.getFullYear() + '-' + (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
}

var a=[1,2,3,1];  防重复
var b=[];
a.forEach(x=> b.push(a));
if(new Set(a).size>1)
    b=1;

document.querySelector('.item').click();  控制模拟点击
document.getElementsByClassName("tabs")[0].remove("cross"); 删除类属性

原文地址:https://www.cnblogs.com/LiuFengH/p/9764471.html