zoukankan      html  css  js  c++  java
  • jqueryMobile 动态添加元素,展示刷新视图方法

    jQuery Mobile的是一个很好的移动开发框架,你可能已经知道,虽然它有很多难以解决的问题,但是我相信后续版本jquery会修复……我是很喜欢jquery的。这并不是说它很完美无暇,很多开发人员遇到的情况也都难解决,比如:尝试使用代码来添加,更新或删除元素,使用JavaScript的页面跳转。在这篇博客文章中,我列出了一些动态添加组建重新刷新的方法。

    1.Textarea field

    1
    2
    $('body').prepend('<textarea id="myTextArea"></textarea>');
    $('#myTextArea').textinput();

    2.Text input field

    1
    2
    $('body').prepend('<input type="text" id="myTextField" />');
    $('#myTextField').textinput();

    3.button

    1
    2
    $('body').prepend('<input type="text" id="myTextField" />');
    $('#myTextField').textinput();

    3.Combobox or select dropdowns

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <label for="sCountry">Country:</label>
    <select name="sCountry" id="sCountry">
        <option value="">Where You Live:</option>
        <option value="ad">Andorra</option>
        <option value="ae">United Arab Emirates</option>
    </select>
     
    var myselect = $("#sCountry");
    myselect[0].selectedIndex = 3;
    myselect.selectmenu('refresh');

    4.最常见的动态添加 listview>li 标签

    1
    2
    3
    4
    5
    6
    7
    <ul id="myList" data-role="listview" data-inset="true">
        <li>A</li>
        <li>B</li>
        <li>C</li>
    </ul>
     
    $('#mylist').listview('refresh');

    5.Slider control

    1
    2
    3
    4
    5
    6
    <div data-role="fieldcontain">
        <label for="slider-2">Input slider:</label>
        <input type="range" id="slider-2" value="25" min="0" max="100" />
    </div>
     
    $('#slider-2').val(80).slider('refresh');

    6.Toggle switch

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    <span><div data-role="fieldcontain">
        <label for="toggle">Flip switch:</label>
        <select name="toggle" id="toggle" data-role="slider">
            <option value="off">Off</option>
            <option value="on">On</option>
        </select>
    </div>
     
    var myswitch = $("#toggle");
    myswitch[0].selectedIndex = 1;
    myswitch .slider("refresh");</span>

    7.Radio

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    <span><div data-role="fieldcontain">
        <fieldset data-role="controlgroup" data-type="horizontal">
            <legend>Layout view:</legend>
                <input type="radio" name="radio-view" value="list"  />
                <label for="radio-view-a">List</label>
                <input type="radio" name="radio-view" value="grid"  />
                <label for="radio-view-b">Grid</label>
                <input type="radio" name="radio-view" value="gallery"  />
                <label for="radio-view-c">Gallery</label>
        </fieldset>
    </div>
     
    $("input[value=grid]").attr('checked',true).checkboxradio('refresh');</span>

    8.Checkboxes

    1
    2
    3
    4
    5
    6
    7
    8
    9
    <div data-role="fieldcontain">
        <fieldset data-role="controlgroup">
            <legend>Agree to the terms:</legend>
            <input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom" />
            <label for="checkbox-1">I agree</label>
        </fieldset>
    </div>
     
    $('#checkbox-1').attr('checked',true).checkboxradio('refresh');
  • 相关阅读:
    Linux实验:NTP网络时间服务器
    局域网访问虚拟机内服务器
    Linux实验:ssh免密码配置
    Kali在NET模式下不能联网的解决方法
    centos7安装redis
    外部服务发现-ingress
    自动化运维-Ansible-playbook
    自动化运维-ansible入门篇
    pod健康检查(liveness probe存活探针&&readiness probe 可读性探针)
    python面试总结4(算法与内置数据结构)
  • 原文地址:https://www.cnblogs.com/xz4062006/p/9239540.html
Copyright © 2011-2022 走看看