JQuery EasyUI(23)

                           第二十三章:NumberBox(数值输入框)组件

学习要点:

  1. 加载方式
  2. 属性列表
  3. 方法列表
  4. 方法列表

 一、加载方式:

1.class加载方式:

<!DOCTYPE html>
<html>
  <head>
    <title>JQuery Easy UI</title>
    <meta charset="utf-8"/>
    <script type="text/javascript" src="easyui/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>     
    <script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>     
    <script type="text/javascript" src="js/index.js"></script> 
    <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css"/>              
</head>
  <body>
     <input type="text" id="box" class="easyui-numberbox">
 </body>
</html>
 


2.JS调用加载:

<!DOCTYPE html>
<html>
  <head>
    <title>JQuery Easy UI</title>
    <meta charset="utf-8"/>
    <script type="text/javascript" src="easyui/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>     
    <script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>     
    <script type="text/javascript" src="js/index.js"></script> 
    <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css"/>              
</head>
  <body>
     <inpu id="box"">
 </body>
</html>
 
$(function(){

   $('#box').numberbox({
      value:500,
  });
});

 

二、属性列表:

NumberBox属性,扩展自ValidateBox属性
属性名说明
disabledboolean是否禁用该字段。默认值false。
valuenumber默认值
minnumber最小值
maxnumber最大值
precisionnumber在十进制分隔符之后显示的最大精度。(即小数点后的显示精度)默认值0
decimalSeparatorstring使用哪一种十进制字符分隔数字的整数和小数部分。默认值为小数点。
groupSeparatorstring使用哪一种字符分隔整数组,以显示成千上万的数据。(比如:99,999,999.00中的‘,’就是该分隔符设置)。
prefixstring前缀字符。(比如:金额的$或者¥)
suffixstring后缀字符。(比如:后置的欧元符号€)
filterfunction(e)定义如何过滤按键,当返回true时则允许输入,反之禁止。
formatterfunction(v)用于格式化数组的函数。返回字符串值以显示到输入框中。
parserfunction(s)用于解析字符串的函数。

 

三、事件列表:

NumberBox事件
事件名事件属性说明
onChangenewValue,oldValue当字段值更改的时候触发。

 

四、方法列表:

NumberBox方法,扩展自ValidateBox(验证框)
方法名传参数说明
options none返回数值输入框属性
destroy none销毁数值输入框对象
disable none禁用字段
enable none启用字段
fix none将输入框职中的值修正为有效的值。
setValue value设置数值输入框的值
getValue none获取数值输入框的值
clear none清除数值输入框的值
reset none重置数值输入框的值

PS:我们可以使用$.fn.numberbox.defaults 重写默认值对象。

<!DOCTYPE html>
<html>
  <head>
    <title>JQuery Easy UI</title>
    <meta charset="utf-8"/>
    <script type="text/javascript" src="easyui/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>     
    <script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>     
    <script type="text/javascript" src="js/index.js"></script> 
    <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css"/>              
</head>
  <body>
     <inpu id="box"">
 </body>
</html>
 
$(function(){

   $('#box').numberbox({
      //value:500,
      //min:5,
      //max:500,
      precision:2,
      //decimalSeparator:':',
      //groupSeparator:',',
      //prefix:'$',
      //suffix:'€',

      /*
      filter:function(){
         return:true,
      },
 
      formater:function(value){
       return:'111,'+ value;
      },

      parser:function(s):{
        return:'111,'+ s;
      },

      onChange:function(newValue,oldValue){
          alert(newValue + '|' + oldValue);
     },
     */

  });

    $(document).click(function(){
      //$('#box').numberbox('fix');
      //console.log($('#box').numberbox('getValue'));
      $('#box').numberbox('setValue',666);
  });
});

 

作者:Roger_CoderLife

链接:https://blog.csdn.net/Roger_CoderLife/article/details/103007189

本文根据网易云课堂JQuery EasyUI视频教程翻译成文档,转载请注明原文出处,欢迎转载

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值