對於單選按鈕它有點複雜(但不是太多)。
首先,您需要一個包含按鈕集的DIV,您可以使用buttonset()方法一次初始化該按鈕集。
接下來,您需要有<label for="this_button_id">
,因爲它是變得可見和可點擊的標籤。因此,使用單選按鈕,標籤變成按鈕,而不是輸入控件。
所以你必須確保<input>
元素的ID和<label>
元素的for=
匹配。
jsFiddle
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#testdiv').buttonset();
}); //END $(document).ready()
</script>
</head>
<body>
<!--<input name="U1" id="U1-1" type="radio" class="languageWidget" />-->
<div id="testdiv">
<input type="radio" id="U1-1" name="U1-1" /><label for="U1-1">Choice 1</label>
<input type="radio" id="U1-2" name="U1-2" checked="checked" /><label for="U1-2">Choice 2</label>
<input type="radio" id="U1-3" name="U1-3" /><label for="U1-3">Choice 3</label>
</div>
</body>
</html>
什麼是它應該做的?沒有這樣的方法http://api.jquery.com/ – zerkms
jQuery沒有按鈕方法,您是否包含jQuery UI? –
你有失敗的小提琴嗎?是所有的CSS和圖像資產加載?你有沒有正確加載jQuery UI庫?還有其他的JQUI功能嗎? –