《jQuery、jQuery UI及jQuery Mobile技巧与示例》——7.4 示例:使用按钮集装饰单选框...

    xiaoxiao2024-01-17  179

    本节书摘来自异步社区《jQuery、jQuery UI及jQuery Mobile技巧与示例》一书中的第7章,第7.4节,作者:【荷】Adriaan de Jonge , 【美】Phil Dutson著,更多章节内容可以访问云栖社区“异步社区”公众号查看

    7.4 示例:使用按钮集装饰单选框

    除了button,jQuery UI还提供了buttonset(按钮集)。代码清单7-4演示了如何使用buttonset将一组单选框装饰成普通按钮的样式,其中每次只能选中一个按钮。

    代码清单7-4 装饰一组单选框

    00 <!DOCTYPE html> 01 02 <html lang="en"> 03 <head> 04  <title>jQuery UI Radio</title> 05  <link type="text/css" rel="stylesheet" href= 06   "http://code.jquery.com/ui/1.8.16/themes/base/jquery-ui.css"> 07 </head> 08 <body> 09 10 <div id="target"> 11  <label for="first">First</label> 12  <input type="radio" name="my-radio" id="first"><br> 13  <label for="second">Second</label> 14  <input type="radio" name="my-radio" id="second"><br> 15  <label for="third">Third</label> 16  <input type="radio" name="my-radio" id="third"><br> 17 </div> 18 19 <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> 20 <script src="http://code.jquery.com/ui/1.8.16/jquery-ui.min.js"> 21 </script> 22 23 <script> 24 // 请将下列代码移至一个外部的.js文件中 25 $(document).ready(function() { 26  27  $('#target').buttonset(); 28   29 }); 30 </script> 31 </body> 32 </html>

    可以将相似的代码用于复选框或其他一组传统的按钮。

    相关资源:jQuery.ui.1.7.2中文文档
    最新回复(0)