Jquery ui jQuery:如何在一个页面上多次使用同一个小部件
jQueryUI似乎对组成小部件的元素的属性很敏感。那么,如何在一个页面\表单中多次使用同一小部件 示例-radio select小部件,它位于使用jQuery ui下载的demo index.html文件中:Jquery ui jQuery:如何在一个页面上多次使用同一个小部件,jquery-ui,radio-button,widget,Jquery Ui,Radio Button,Widget,jQueryUI似乎对组成小部件的元素的属性很敏感。那么,如何在一个页面\表单中多次使用同一小部件 示例-radio select小部件,它位于使用jQuery ui下载的demo index.html文件中: <!DOCTYPE html> <html> <head> ... $(function(){ $("#radioset").buttonset(); }
<!DOCTYPE html>
<html>
<head>
...
$(function(){
$("#radioset").buttonset();
}
...
</head>
<body>
...
<form style="margin-top: 1em;">
<div id="radioset">
<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>
</form>
...
</body>
</html>
...
$(函数(){
$(“#无线电集”).buttonset();
}
...
...
选择1
选择2
选择3
...
那么,我应该添加什么代码来创建具有不同单选按钮集的第二个div
$(function(){
$("#radioset2").buttonset();
}
<div id="radioset2">
Wich将选择radioset类而不是id,这样您就可以拥有多个
针对您的评论:
$(function(){
$("#radioset1").buttonset();
$("#radioset2").buttonset();
}
<form name="form1" style="margin-top: 1em;">
<div id="radioset1">
<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>
</form>
<form name="form2" style="margin-top: 1em;">
<div id="radioset2">
<input type="radio" id="radioAgain1" name="radio" /><label for="radio1">Choice 1</label>
<input type="radio" id="radioAgain2" name="radio" checked="checked" /><label for="radio2">Choice 2</label>
<input type="radio" id="radioAgain3" name="radio" /><label for="radio3">Choice 3</label>
</div>
</form>
$(函数(){
$(“#radioset1”).buttonset();
$(“#radioset2”).buttonset();
}
选择1
选择2
选择3
选择1
选择2
选择3
我看不出上述措施不起作用的理由
Wich将选择radioset类而不是id,这样您就可以拥有多个
针对您的评论:
$(function(){
$("#radioset1").buttonset();
$("#radioset2").buttonset();
}
<form name="form1" style="margin-top: 1em;">
<div id="radioset1">
<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>
</form>
<form name="form2" style="margin-top: 1em;">
<div id="radioset2">
<input type="radio" id="radioAgain1" name="radio" /><label for="radio1">Choice 1</label>
<input type="radio" id="radioAgain2" name="radio" checked="checked" /><label for="radio2">Choice 2</label>
<input type="radio" id="radioAgain3" name="radio" /><label for="radio3">Choice 3</label>
</div>
</form>
$(函数(){
$(“#radioset1”).buttonset();
$(“#radioset2”).buttonset();
}
选择1
选择2
选择3
选择1
选择2
选择3
我看不出有任何理由不使用上述方法。我相信这就是您想要的,以及如何将两台不同的收音机组合成一种形式的示例。请注意输入的名称
$(function(){
$(".radioset").buttonset();
}
<form name="form1" style="margin-top: 1em;">
<div id="radioset1" class="radioset">
<input type="radio" id="radioset1-1" name="radio1" /><label for="radioset1-1">Choice 1</label>
<input type="radio" id="radioset1-2" name="radio1" checked="checked" /><label for="radioset1-2">Choice 2</label>
<input type="radio" id="radioset1-3" name="radio1" /><label for="radioset1-3">Choice 3</label>
</div>
<div id="radioset2" class="radioset">
<input type="radio" id="radioset2-1" name="radio2" /><label for="radioset2-1">Choice 1</label>
<input type="radio" id="radioset2-2" name="radio2" checked="checked" /><label for="radioset2-2">Choice 2</label>
<input type="radio" id="radioset2-3" name="radio2" /><label for="radioset2-3">Choice 3</label>
</div>
</form>
$(函数(){
$(“.radioset”).buttonset();
}
选择1
选择2
选择3
选择1
选择2
选择3
我相信这就是您想要的,以及如何将两台不同的收音机组合成一种形式的示例。请注意输入的名称
$(function(){
$(".radioset").buttonset();
}
<form name="form1" style="margin-top: 1em;">
<div id="radioset1" class="radioset">
<input type="radio" id="radioset1-1" name="radio1" /><label for="radioset1-1">Choice 1</label>
<input type="radio" id="radioset1-2" name="radio1" checked="checked" /><label for="radioset1-2">Choice 2</label>
<input type="radio" id="radioset1-3" name="radio1" /><label for="radioset1-3">Choice 3</label>
</div>
<div id="radioset2" class="radioset">
<input type="radio" id="radioset2-1" name="radio2" /><label for="radioset2-1">Choice 1</label>
<input type="radio" id="radioset2-2" name="radio2" checked="checked" /><label for="radioset2-2">Choice 2</label>
<input type="radio" id="radioset2-3" name="radio2" /><label for="radioset2-3">Choice 3</label>
</div>
</form>
$(函数(){
$(“.radioset”).buttonset();
}
选择1
选择2
选择3
选择1
选择2
选择3
它实际上并不要求对表单进行包装。相反,您只需要确保您的广播组具有不同的名称。这将得到更详细的解释。它实际上不要求对表单进行包装。相反,您只需要确保您的广播组具有不同的名称。这将得到更详细的解释详细信息。非常确定jquery需要它们成为某种东西。试试看。你可以在一个页面上有许多收音机,这很简单。你是对的,但有一个关键的补充-两个收音机必须是分开的形式,否则所有的单选按钮都绑在一起。事实上,我看不出其中的逻辑,但我测试了它,结果不是这样他是区分元素。@lznogood-做些改变,我会接受你的答案。谢谢!!你必须把它包装成一个表单,这似乎很荒谬。奇怪,我明白了。非常确定jquery需要它们。试试看。你可以在一个页面上有很多收音机,这很简单。你是对的,但有一个关键的补充-两台收音机需要以单独的形式,否则所有单选按钮都绑定在一起。事实上,我看不出其中的逻辑,但我测试了它,这就是区别元素。@lznogood-做更改,我接受你的答案。谢谢!!你必须将其包装在一个表单中似乎很荒谬。奇怪,明白了。