bootstrip radio button 按钮样式的单选组合.

单选样式.jpg

需要导入bootstrip3.
模板代码是

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">规格:</label>
                                    <form class="col-sm-4" autocomplete="off" data-toggle="buttons">
                                        <label class="btn btn-primary">
                                            <input type="radio" name="type"
                                                   checked='checked'
                                                   value="a"> 2核4G
                                        </label>
                                        <label class="btn btn-primary">
                                            <input type="radio" name="type"
                                                   value="b"> 2核4G
                                        </label>
                                        <label class="btn btn-primary">
                                            <input type="radio" name="type"
                                                   value="c"> 2核4G
                                        </label>
                                        <label class="btn btn-primary">
                                            <input type="radio" name="type"
                                                   value="d"> 2核4G
                                        </label>
                                        <label class="btn btn-primary">
                                            <input type="radio" name="type"
                                                   value="e"> 2核4G
                                        </label>
                                        <label class="btn btn-primary">
                                            <input type="radio" name="type"
                                                   value="f"> 2核4G
                                        </label>
                                        <label class="btn btn-primary">
                                            <input type="radio" name="type"
                                                   value="g"> 2核4G
                                        </label>
                                        <label class="btn btn-primary">
                                            <input type="radio" name="type"
                                                   value="h"> 2核4G
                                        </label>
                                    </form>
                                </div>
  • 打开浏览器console,输入:
$('input[name="type"]:checked').val();

就可以显示选中的value值.

data-toggle="buttons"这个是把样式设置成了按钮样式.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容