<span class="answerBox">
<a name="checkboxtag" class="largecheckbox" onclick="selectQuestionAnswer(this);"></a>
<input name="answers" value="8ad6a4124641ec5001464d856b23436c" class="checkbox displaynone" type="radio">
</span>
我尝试过使用.prop()
jQuery('input:checkbox[value="8ad6a4124641ec5001464d856b23436c"]').prop("checked", true);
试图触发点击:
jQuery('input:checkbox[value="8ad6a4124641ec5001464d856b23436c"]').trigger('click');
尝试编辑其兄弟的课程(因为点击它会改变兄弟姐妹的课程,而不是别的):
jQuery('input:checkbox[value="8ad6a4124641ec5001464d856b23436c"]').siblings('.largecheckbox').trigger('click');
然后我不确定我是否正确选择它。我试图在复选框上切换高亮显示,但它没有做任何事情..
jQuery('input:checkbox[value="8ad6a4124641ec5001464d856b23436c"]').siblings('.largecheckbox').toggle('highlight');
jQuery('input:checkbox[value="8ad6a4124641ec5001464d856b23436c"]').toggle('highlight');
是否无法选中此复选框?我昨天和今天一整天都在努力。
感谢阅读和任何帮助!
编辑:你们是众神。有用。我使用了jQuery('input:radio[value="8ad6a4124641ec5001464d856b23436c"]').siblings().toggle('highlight');
确保它能够正常工作。谢谢。 然后我使用了触发器('click');它做了。我所要做的就是使用无线电选择器选择它。谢谢大家的努力。
答案 0 :(得分:1)
您正尝试使用复选框选择器
更改<input type="radio">
将一个或另一个修复为应该是什么
当您更改为
时,您的代码可以正常工作<input name="answers" value="8ad6a4124641ec5001464d856b23436c" type="checkbox">
如果您想作为广播使用:radio
选择器
的 DEMO 强>
答案 1 :(得分:0)
你的第一个解决方案非常接近。只需将冒号更改为句点。
double Rate1 = Weeks * ECONOMY_WEEKLY;
double Rate2 = (Weeks * ECONOMY_WEEKLY) + (Days * ECONOMY_DAILY);
double Rate3 = (Days * ECONOMY_DAILY);
switch (FirstTypeLetter) {
case 'E':
if ((Rate1 > Rate2) & (Rate1 > Rate3)) {
System.out.println("This is the best rate for a" + " " + color + " " + Type + " vehicle for" + " " + Days + "days:" + Rate1);
}
else if ((Rate2 > Rate1) & (Rate2 > Rate3)){
System.out.println("This is the best rate for a" + " " + color + " " + Type + " vehicle for" + " " + Days + "days:" + Rate2);
}
else if ((Rate3 > Rate2) & (Rate3 > Rate1)) {
System.out.println("This is the best rate for a" + " " + color + " " + Type + " vehicle for" + " " + Days + "days:" + Rate3);
}
break;
case 'F':
double FullRate1 = Weeks * FULL_WEEKLY;
double FullRate2 = (Weeks * FULL_WEEKLY) + (Days * FULL_DAILY);
double FullRate3 = (Days * ECONOMY_DAILY);
if ((Rate1 > Rate2) & (Rate1 > Rate3)) {
System.out.println("This is the best rate for a" + " " + color + " " + Type + " vehicle for" + " " + Days + "days:" + FullRate1);
}
else if ((FullRate2 > FullRate1) & (FullRate2 > FullRate3)) {
System.out.println("This is the best rate for a" + " " + color + " " + Type + " vehicle for" + " " + Days + "days:" + FullRate2);
}
else if ((FullRate3 > FullRate1) & (FullRate3 > FullRate2)) {
System.out.println("This is the best rate for a" + " " + color + " " + Type + " vehicle for" + " " + Days + "days:" + FullRate3);
}
break;
default:
System.out.println("Try Again!");
break;
}
答案 2 :(得分:0)
我正在使用此函数来检查您需要传递复选框的jquery对象所需的任何复选框
function toggleCheck(elm, checked) {
if (elm.is(":checked") != checked) {
elm.click();
}
}
toggleCheck($('[name="answers]'), true) // will check if not already checked
toggleCheck($('[name="answers]'), false) // will un check if already checked
答案 3 :(得分:0)
您没有匹配的元素,为changed$('input:radio[value="8ad6a4124641ec5001464d856b23436c"]')
,
答案 4 :(得分:-1)
将收音机更改为复选框后,请尝试此操作。
$(function(){
$(".largecheckbox").click(function(){
$(this).next("input:checkbox").attr("checked",true);
});
});