• <small id='aDyHe'></small><noframes id='aDyHe'>

    1. <i id='aDyHe'><tr id='aDyHe'><dt id='aDyHe'><q id='aDyHe'><span id='aDyHe'><b id='aDyHe'><form id='aDyHe'><ins id='aDyHe'></ins><ul id='aDyHe'></ul><sub id='aDyHe'></sub></form><legend id='aDyHe'></legend><bdo id='aDyHe'><pre id='aDyHe'><center id='aDyHe'></center></pre></bdo></b><th id='aDyHe'></th></span></q></dt></tr></i><div id='aDyHe'><tfoot id='aDyHe'></tfoot><dl id='aDyHe'><fieldset id='aDyHe'></fieldset></dl></div>

        <bdo id='aDyHe'></bdo><ul id='aDyHe'></ul>
      <legend id='aDyHe'><style id='aDyHe'><dir id='aDyHe'><q id='aDyHe'></q></dir></style></legend>
      <tfoot id='aDyHe'></tfoot>

        如何自定义水平 jQuery-mobile 单选按钮

        How to customize horizontal jQuery-mobile radio buttons(如何自定义水平 jQuery-mobile 单选按钮)
            • <bdo id='p0Goc'></bdo><ul id='p0Goc'></ul>

              <legend id='p0Goc'><style id='p0Goc'><dir id='p0Goc'><q id='p0Goc'></q></dir></style></legend>
                <tbody id='p0Goc'></tbody>
            • <small id='p0Goc'></small><noframes id='p0Goc'>

                  <i id='p0Goc'><tr id='p0Goc'><dt id='p0Goc'><q id='p0Goc'><span id='p0Goc'><b id='p0Goc'><form id='p0Goc'><ins id='p0Goc'></ins><ul id='p0Goc'></ul><sub id='p0Goc'></sub></form><legend id='p0Goc'></legend><bdo id='p0Goc'><pre id='p0Goc'><center id='p0Goc'></center></pre></bdo></b><th id='p0Goc'></th></span></q></dt></tr></i><div id='p0Goc'><tfoot id='p0Goc'></tfoot><dl id='p0Goc'><fieldset id='p0Goc'></fieldset></dl></div>
                • <tfoot id='p0Goc'></tfoot>

                • 本文介绍了如何自定义水平 jQuery-mobile 单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我们的客户需要为 jQuery-mobile 定制设计单选按钮样式.实际上它与水平模式下默认的 jQuery-mobile 单选按钮设计非常相似.例如 jQuery-mobile 将水平单选按钮定义为

                  Our client need a custom design radio button style for the jQuery-mobile. Actually it's very similar to default jQuery-mobile radio button design in horizontal mode. For example jQuery-mobile define the horizontal radio button as

                  <fieldset data-role="controlgroup" data-type="horizontal">
                      <legend>I like to buy and wear trendy must-haves</legend>
                      <input type="radio" name="radio-choice" id="radio-choice-1" value="choice-1" checked="checked"  />
                      <label for="radio-choice-1">1</label>
                  
                      <input type="radio" name="radio-choice" id="radio-choice-2" value="choice-2"  />
                      <label for="radio-choice-2">2</label>
                  
                      <input type="radio" name="radio-choice" id="radio-choice-3" value="choice-3"  />
                      <label for="radio-choice-3">3</label>
                  
                      <input type="radio" name="radio-choice" id="radio-choice-4" value="choice-4"  />
                      <label for="radio-choice-4">4</label>
                  
                      <input type="radio" name="radio-choice" id="radio-choice-5" value="choice-5"  />
                      <label for="radio-choice-5">5</label>
                  </fieldset>
                  

                  此外,我们的客户希望在 labell 下方显示默认单选按钮.例如下面的图片

                  Additionally our client wants to display the default radio button below the lablel. For example following image

                  我想知道 jQuery-mobile 是否允许我们显示默认单选按钮?如果可以,你能举个例子吗?

                  I would like to know does jQuery-mobile allow us to display the default radio buttons ? If so can you give an example ?

                  还是我们需要自定义这个?

                  Or should we need to customize this ?

                  推荐答案

                  解决方案

                  首先,它不能通过 jQM 配置来完成.这必须通过 jquery 手动创建(与任何其他 jQM 小部件一样,包括字段集).

                  Solution

                  First thing, it can't be done through the jQM configuration. This must be created manually through a jquery (like any other jQM widget, including fieldset).

                  我为您创建了一个工作示例:http://jsfiddle.net/Gajotres/779Kn/

                  I have created an working example for you: http://jsfiddle.net/Gajotres/779Kn/

                  您只需要再做一件事,我不想打扰自定义图像,所以我使用为我的另一个示例创建的图像:https://stackoverflow.com/a/13634738/1848600

                  Your only need to do one more thing, I didn't want to bother with a custom images so I am using images created for my other example: https://stackoverflow.com/a/13634738/1848600

                  这里需要一个javascript:

                  Here's an javascript needed:

                  $(document).on('pagebeforeshow', '#index', function(){     
                      $('<div>').addClass('checkBox').appendTo('fieldset div div.ui-radio label');
                      $('input[type="radio"]').each(function(){        
                          ($(this).is(':checked')) ? $(this).next().find(".checkBox").addClass('checked') : $(this).next().find(".checkBox").addClass('not-checked');
                      });
                      
                      $(document).on('click', '.ui-radio', function(){      
                          $('input[type="radio"]').each(function(){  
                              $(this).next().find(".checkBox").addClass('not-checked').removeClass('checked');
                          }); 
                          
                          if($(this).find('input[type="radio"]').is(':checked')){
                             $(this).find('label div.checkBox').removeClass('checked').addClass('not-checked'); 
                             $(this).find('input[type="radio"]').attr('checked' , false);
                          } else {
                             $(this).find('label div.checkBox').removeClass('not-checked').addClass('checked');             
                             $(this).find('input[type="radio"]').attr('checked' , true);
                          }        
                      });  
                  });
                  

                  这是css:

                  .checkBox{
                      width: 18px;
                      height: 18px;
                      background: #d9d9d9;
                      border-radius: 3px;  
                      margin: 0 auto;
                      margin-bottom: 5px;
                  }
                  
                  .not-checked, .checked {
                      background-image: url("http://www.fajrunt.org/icons-18-white.png");
                      background-repeat: no-repeat;
                  }
                  
                  .not-checked {
                      background-position: -18px 0;       
                      background-color:#d9d9d9;
                  }
                  
                  .checked {
                      background-position: -720px 0;    
                      background-color:#6294bc;
                  }
                  

                  如果你能等几个小时,我会更新一张图片,我不能从我当前的位置更新.

                  If you can wait few hours I will update a picture, I can't do it from my current location.

                  如果您想了解有关如何自定义 jQuery Mobile 页面和小部件的更多信息,请查看此 文章.它附带了许多工作示例,包括为什么 !important 对于 jQuery Mobile 是必需的.

                  If you want to find more about how to customize jQuery Mobile page and widgets then take a look at this article. It comes with a lot of working examples, including why is !important necessary for jQuery Mobile.

                  这篇关于如何自定义水平 jQuery-mobile 单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  append() 方法在被选元素的结尾(仍然在内部)插入指定内容。 语法: $(selector).append( content ) var creatPrintList = function(data){ var innerHtml = ""; for(var i =0;i data.length;i++){ innerHtml +="li class='contentLi'"; innerHtml +="a href
                  quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
                  How do I make a TextGeometry multiline? How do I put it inside a square so it wraps like html text does inside a div?(如何制作 TextGeometry 多线?如何将它放在一个正方形内,以便它像 html 文本一样包裹在 div 内?) - IT屋-程序员软件开发技术分享社
                  ExecJS::ProgramError: SyntaxError: Reserved word quot;functionquot;(ExecJS::ProgramError: SyntaxError: 保留字“function)
                  Infinite scroll and will_paginate appending the #39;next page#39; of items multiple times(无限滚动和 will_paginate 多次附加项目的“下一页)
                  What is cleanest way to turn Array of JQuery Promises into a JQuery Promise of an Array?(将 JQuery Promise 数组转换为数组的 JQuery Promise 的最简洁方法是什么?)
                    <bdo id='91UQb'></bdo><ul id='91UQb'></ul>
                    <i id='91UQb'><tr id='91UQb'><dt id='91UQb'><q id='91UQb'><span id='91UQb'><b id='91UQb'><form id='91UQb'><ins id='91UQb'></ins><ul id='91UQb'></ul><sub id='91UQb'></sub></form><legend id='91UQb'></legend><bdo id='91UQb'><pre id='91UQb'><center id='91UQb'></center></pre></bdo></b><th id='91UQb'></th></span></q></dt></tr></i><div id='91UQb'><tfoot id='91UQb'></tfoot><dl id='91UQb'><fieldset id='91UQb'></fieldset></dl></div>

                      <small id='91UQb'></small><noframes id='91UQb'>

                        <legend id='91UQb'><style id='91UQb'><dir id='91UQb'><q id='91UQb'></q></dir></style></legend>
                          <tbody id='91UQb'></tbody>

                        1. <tfoot id='91UQb'></tfoot>