【发布时间】:2019-05-04 02:48:02
【问题描述】:
我正在创建一个自定义 sharepoint 列表,并为 隐藏/显示/清除 数据输入字段、下拉列表和日期编写了一些 jQuery 逻辑。我需要将下拉菜单更改为 yes/no 的单选按钮,但我无法弄清楚如何在 jQuery 逻辑中更改我的 if 语句,我写的是针对单选按钮并检查它们的值。
有谁知道我可以用 jquery 定位单选按钮组并获取选中的值?
我试图用
来定位他们if($("input[title='Did the Rep call a TM prior to start of shift or leaving for the day?']:checked").val() == "No") - 没用。
$("input[title='Did the Rep call a TM prior to start of shift or leaving for the day?']:checked").change(function() {
if ($("input[title='Did the Rep call a TM prior to start of shift or leaving for the day?']:checked").val() == "No"){
// *******************************Show accountability created? question***********************************
$('nobr:contains("Accountability discussion created?")').closest('tr').show();
// *******************************Reset values from previous "Yes" selection*****************************
$("select[title='Did the Rep report there was an issue with MyWorkLife?']").val("Select Yes or No");
$("select[title='Did the rep send screenshots?']").val("Select Yes or No");
// *******************************Hide questions from previous "Yes" selection***************************
$('nobr:contains("Did the Rep report there was an issue with MyWorkLife?")').closest('tr').hide();
$('nobr:contains("Did the rep send screenshots?")').closest('tr').hide();
}
}```
I expect these different rows in the table to either be shown or hidden when the if statement is met - this is only partial code there is "else if" and "else" statements after but didn't think necessary to paste it all.
【问题讨论】:
标签: jquery sharepoint radio-button