• mui 滑块开关 进度条 以及如何获取值


    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <title></title>
        <script src="js/mui.min.js"></script>
        <link href="css/mui.min.css" rel="stylesheet"/>
        <script type="text/javascript" charset="utf-8">
              mui.init();
        </script>
    </head>
    <body>
    <header class="mui-bar mui-bar-nav">
        <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
        <h1 class="mui-title">hello</h1>
    </header>
    
    <div class="mui-content">
        <!--有准确值得进度条-->
        <div style="padding: 20px;">
            <div id="demo1" class="mui-progressbar">
                <span></span>
            </div>
        </div>
        <div style="padding: 0px 20px;">
            <button type="button" onClick="setPro()">展示进度条</button>
        </div>
        
        <!--获取滑块值-->
        <div class="mui-input-row mui-input-range">
            <label>Range</label>
            <input type="range" min="0" max="100" id="rangel">
        </div>
        <div style="padding: 20px;">
            <input type="button" class="mui-btn" value="获取滑块值" onClick="getVal()">
        </div>
        
        <!--滑块开关 绿色的-->
        <div class="mui-switch">
            <div class="mui-switch-handle"></div>
        </div>
        <br>
        <div class="mui-switch mui-active">
            <div class="mui-switch-handle"></div>
        </div>
        
        <br>
        <!--蓝色的滑块-->
        <div class="mui-switch mui-active mui-switch-blue">
            <div class="mui-switch-handle"></div>
        </div>
        <br>
        <!--也可以在这个div标签里加上点击事件   onClick="get_active()"-->
        <div class="mui-switch mui-switch-blue" id="mySwitch">
            <div class="mui-switch-handle"></div>
        </div>
        <div style="padding: 0px 20px;">
            <button type="button" onClick="get_active()">获取滑块状态</button>
        </div>
        
    </div>
    </body>
    <script type="text/javascript">
        /*有准确值得进度掉 */
        function setPro(){
            var obj = mui('#demo1');
            var bl = 0;
            setInterval(function(){
                obj.progressbar({progress:bl}).show();
                bl += 10;
            },1000)
        }
        
        /*获取滑块值*/
        function getVal(){
            var rangeobj = mui('#rangel');
            mui.toast(rangeobj[0].value);
        }
        
        /*获取滑块值*/
        function get_active(){
            var obj = document.getElementById('mySwitch');
            if(obj.classList.contains('mui-active')){
                mui.toast('on');
            }else{
                mui.toast('off');
            }
        }
        
        
        /*监听滑块的变化*/
    /*    mui.plusReady(function(){}) //加上此方法必须在真机上运行才有效果*/
        document.getElementById('mySwitch').addEventListener('toggle',function(e){
                if(e.detail.isActive){
                    mui.toast('on');
                }else{
                    mui.toast('off');
                }
            })
    </script>
    </html>
  • 相关阅读:
    写一个列表生成式,产生一个公差为11的等差数列
    如果对方网站反爬取,封IP了怎么办?
    为什么会选择redis数据库?
    你是否了解谷歌的无头浏览器?
    遇到的反爬虫策略以及解决方法?
    常见的HTTP方法有哪些?
    遇到反爬机制怎么处理?
    列举网络爬虫所用到的网络数据包,解析包?
    python中的关键字yield有什么作用?
    如下代码输出的是什么?
  • 原文地址:https://www.cnblogs.com/zc290987034/p/8847328.html
Copyright © 2020-2023  润新知