zoukankan      html  css  js  c++  java
  • 【jQuery】 实用 js

    【jQuery】 实用 js

     1. int 处理

     parseInt("123") // int 转换
    
     isNaN(page) // 判断是否是int类型

    2. string 处理

    // C# string.Format 用于替换字符串拼接
    function stringFormate() {
    if (arguments.length == 0) return null; var str = arguments[0]; for (var i = 1; i < arguments.length; i++) { var re = new RegExp('\{' + (i - 1) + '\}', 'gm'); str = str.replace(re, arguments[i]); } return str; };

    3. date 处理


    //
    时间转字符串 function dateFormat(date) { return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate(); } // 字符串转时间 function convertToDate(date) { var array = date.split("-"); if (array.length == 3) { return new Date(array[0], array[1] - 1, array[2]); } return new Date(); }

    4. undefined 判断

    function isUndefined(value) {
        return typeof (value) == "undefined";
    }

    5. radio

    function getCheckedRadioValue(name) {
        return $("input:radio:checked[name='" + name + "']").val();
    }

    6. select

    // 选中指定 value 的节点
    function selectOption(id, value) { 
        $("#" + id + " option[value='" + value + "']").attr("selected", "selected");
    }
    // 返回选中节点的 value
    function getSelectVal(id) { 
        $("#" + id).val();
    }

    待续。。。

  • 相关阅读:
    centos networkmanager 和 network配置冲突
    Struts ajax json重新整理
    Struts2 ajax json小例子
    (转)json-lib 的maven dependency
    Struts2文件下载
    jQuery自定义滚动条插件mCustomScrollbar
    Struts2自定义拦截器
    Spring的自动装配在session监听器失效
    mysql 分组+排序+限定
    mysql触发器
  • 原文地址:https://www.cnblogs.com/fzz2727551894/p/4170285.html
Copyright © 2011-2022 走看看