JQuery UI object button bar that works like radio buttons

旧巷老猫 提交于 2019-12-22 05:41:09

问题


I'd like to make a control or use a control in jQuery that acts like a series of radio buttons but that looks like solid buttons instead of the radio circle. They'd look like a horizontal menu but only one could be selected at one time.


回答1:


jQuery UI added a widget for this in 1.8, check out jQuery UI Buttons.

The markup looks like this (straight from the demo), just use a container like a <div>:

<div id="radio">
  <input type="radio" id="radio1" name="radio" /><label for="radio1">Choice 1</label>
  <input type="radio" id="radio2" name="radio" checked="checked" /><label for="radio2">Choice 2</label>
  <input type="radio" id="radio3" name="radio" /><label for="radio3">Choice 3</label>
</div>

Then call .buttonset():

$("#radio").buttonset();


来源:https://stackoverflow.com/questions/3272663/jquery-ui-object-button-bar-that-works-like-radio-buttons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!