我根据某个值将单选按钮的选中状态设置为 true;
var radioValue = data.Activity.Answer == "Please add your answer" ? "valueA" : data.Activity.Answer;
$("input[name=optionRadio" + currentIndex + "][value=" + radioValue + "]").attr('checked', true);
对我来说,提前检查该单选按钮是否确实存在于幻灯片上的最佳方法是什么?
最佳答案
您可以检查 jQuery 对象的长度
来找出它:
if($("input[name=optionRadio" + currentIndex + "]").length > 0 ){
// Radio button actually exists...
}
关于javascript - 检查单选按钮是否存在 jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32523432/