10HUI - 按钮(hui-button)

简介: 10HUI - 按钮(hui-button)

示例图片

普通按钮

<button type="button" class="hui-button">普通按钮</button>

Loading按钮

点击按钮后出现Loading动画,并能够对提交中进行判断,避免重复提交。dom 结构和普通按钮一样,使用js来控制Loading效果:

<button type="button" class="hui-button" id="btn1">Loading按钮</button>
hui(按钮选择器).loadingButton(msg)

功能:在普通按钮上产生loading效果

参数:提示内容

返回:无

hui(按钮选择器).buttonIsLoading()

功能:判断按钮是否处于加载状态

参数:无

返回:布尔类型 true / false

hui(按钮选择器).resetLoadingButton()

功能:恢复按钮原始状态

参数:无

返回:无

完整代码:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>HUI - 按钮组件</title>
<link rel="stylesheet" type="text/css" href="../css/hui.css" />
</head>
<body>
<header class="hui-header">
    <div id="hui-back"></div>
    <h1>HUI - 按钮组件</h1>
</header>
<div class="hui-wrap">
    <div class="hui-common-title" style="margin-top:15px;">
        <div class="hui-common-title-line"></div>
        <div class="hui-common-title-txt">按钮组件演示</div>
        <div class="hui-common-title-line"></div>
    </div>
    <div style="padding:28px 20px 10px 20px;" id="btnList1">
        <button type="button" class="hui-button hui-fl">普通按钮</button>
        <button type="button" class="hui-button hui-danger hui-fl" style="margin-left:10px;">警告按钮</button>
        <button type="button" class="hui-button hui-primary hui-fl" style="margin-left:10px;">主要按钮</button>
    </div>
    <div style="padding:1px 20px;" id="btnList2">
        <button type="button" class="hui-button hui-button-large" style="margin-top:15px;">宽度100%的按钮</button>
        <button type="button" class="hui-button hui-button-large hui-primary" style="margin-top:15px;">宽度100%的按钮</button>
        <button type="button" class="hui-button hui-button-large hui-danger" style="margin-top:15px;">宽度100%的按钮</button>
        <button type="button" class="hui-button hui-button-large" style="margin-top:15px;" disabled="disabled">禁用的按钮</button>
    </div>
    <div style="padding:10px 20px;">
        <button type="button" class="hui-button hui-button-large" style="margin-top:15px;" id="loadingBtn1">loading按钮</button>
        <button type="button" class="hui-button hui-button-large" style="margin-top:15px;" id="loadingBtn2">点击后loading并自动还原</button>
        <button type="button" class="hui-button hui-button-large" style="margin-top:15px;"><span class="hui-icons hui-icons-warn"></span>图标按钮</button>
    </div>
    <div style="padding:10px 20px;">
        <button type="button" class="hui-button hui-button-small hui-fl">小按钮</button>
        <button type="button" class="hui-button hui-button-small hui-danger hui-fl" style="margin:0px 10px;">小按钮</button>
        <button type="button" class="hui-button hui-button-small hui-primary hui-fl">小按钮</button>
    </div>
</div>
<script src="../js/hui.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
hui('#btnList1').find('button').click(function(){hui.toast('ok');});
hui('#btnList2').find('button').click(function(){hui.toast('Hi...');});
hui('#loadingBtn1').loadingButton();
hui('#loadingBtn2').click(function(){
    if(hui(this).buttonIsLoading()){return false;}
    hui(this).loadingButton('加载中...');
    setTimeout(function(){
        hui('#loadingBtn2').resetLoadingButton();
    }, 2000);
});
</script>
</body>
</html>
目录
相关文章
15HUI - Loading动画(hui.loading)
15HUI - Loading动画(hui.loading)
53 0
15HUI - Loading动画(hui.loading)
|
JavaScript
25HUI - 下拉刷新(hui-loading-wrap)
25HUI - 下拉刷新(hui-loading-wrap)
63 0
12HUI - Toast提示框(hui.toast)
12HUI - Toast提示框(hui.toast)
60 0
03HUI -基础文本(hui-common-title)
03HUI -基础文本(hui-common-title)
52 0
11HUI - 数字标识(hui-badge)
11HUI - 数字标识(hui-badge)
48 0
11HUI - 数字标识(hui-badge)
17HUI - 进度条(hui-progress)
17HUI - 进度条(hui-progress)
42 0
17HUI - 进度条(hui-progress)
18HUI - popoverMsg(hui('#btn1').popoverMsg)
18HUI - popoverMsg(hui('#btn1').popoverMsg)
42 0
|
JavaScript
22HUI - 轮播组件(hui-swipe)
22HUI - 轮播组件(hui-swipe)
58 0
13HUI - 模态对话框(hui.alert、hui.confirm)
13HUI - 模态对话框(hui.alert、hui.confirm)
75 0
14HUI - 全屏消息(hui.blackMask)
14HUI - 全屏消息(hui.blackMask)
46 0