最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to get a UIKit Button Group to function as radio buttons in a form - Stack Overflow

programmeradmin1浏览0评论

Yoothemes UIKit () provides a way of making a button group appear to function like radio buttons. See about half way down on this page: .html

But the documentation is entirely missing on how to make the button group actually function like radio buttons in a form. Grateful for advice on this.

Currently if I use them in a form any button clicked submits the form. example form for iphone ordering options:

   <form>
      <div class="uk-button-group uk-margin-bottom" data-uk-button-radio>
        <button class="uk-button uk-button-large">16gb</button>
        <button class="uk-button uk-button-large">32gb</button>
        <button class="uk-button uk-button-large">64gb</button>
      </div>
      <div class="uk-button-group uk-margin-bottom" data-uk-button-radio>
        <button class="uk-button uk-button-large">Space Gray</button>
        <button class="uk-button uk-button-large">Gold</button>
        <button class="uk-button uk-button-large">Silver</button>
      </div>
      <button type="submit" class="uk-button uk-button-large uk-button-primary"><i class="uk-icon-magnifier"></i> Review and Order</button>
    </form>

Yoothemes UIKit (http://getuikit.) provides a way of making a button group appear to function like radio buttons. See about half way down on this page: http://getuikit./docs/button.html

But the documentation is entirely missing on how to make the button group actually function like radio buttons in a form. Grateful for advice on this.

Currently if I use them in a form any button clicked submits the form. example form for iphone ordering options:

   <form>
      <div class="uk-button-group uk-margin-bottom" data-uk-button-radio>
        <button class="uk-button uk-button-large">16gb</button>
        <button class="uk-button uk-button-large">32gb</button>
        <button class="uk-button uk-button-large">64gb</button>
      </div>
      <div class="uk-button-group uk-margin-bottom" data-uk-button-radio>
        <button class="uk-button uk-button-large">Space Gray</button>
        <button class="uk-button uk-button-large">Gold</button>
        <button class="uk-button uk-button-large">Silver</button>
      </div>
      <button type="submit" class="uk-button uk-button-large uk-button-primary"><i class="uk-icon-magnifier"></i> Review and Order</button>
    </form>
Share Improve this question asked Apr 29, 2014 at 2:44 larpolarpo 1,1631 gold badge10 silver badges18 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

This worked for me:

<div class="uk-button-group" data-uk-button-radio>
    <label class="uk-button">
        <input type="radio" name="gender" value="0" style="display:none;"/>
        Male
    </label>
    <label class="uk-button">
        <input type="radio" name="gender" value="1" style="display:none;"/>
        Female
    </label>
</div>

Alternatively you could do something like this too:

<div class="uk-button-group" data-uk-button-radio>
    <label class="uk-button" for="male">Male</label>
    <label class="uk-button" for="female">Female</label>
    <input type="radio" id="male" name="gender" value="0" style="display:none;"/>
    <input type="radio" id="female" name="gender" value="1" style="display:none;"/>
</div>

Hope it helps.

发布评论

评论列表(0)

  1. 暂无评论