JQuery Mobile:单选按钮无法反映

时间:2015-07-25 02:56:53

标签: javascript jquery button radio

我已经为jQuery mobile创建了单选按钮,我已经声明了变量和值,但为什么不反映,任何人都可以帮助我用不同的代码尝试很多次但仍然无效。

这是实时代码

https://jsfiddle.net/h47Lfnbp

var type = "Contractor";
$('input[name=CustCat]').filter('[value=Contractor]').attr('checked', true);

非常感谢。

2 个答案:

答案 0 :(得分:0)

对不起我也是一个菜鸟儿子,我完全理解你的意思。但我想你不能选择你选择的单选按钮,试试这个。如果我误解了你的问题,请告诉我PDF

$("#Architect").change(function(){
         if ($(this).prop("checked")){
           alert("you choose Architect");
           $('input[name=CustCat]').filter('[value=Architect]').attr('checked', true);
         };
         if($(this).prop("checked")==false){
           alert("you cancel Architect");
           $('input[name=CustCat]').filter('[value=Architect]').attr('checked', false);
         }
       });

并且您的$("#ul-CustTypeDisplay").enhanceWithin();显示错误,因此我将其转换为评论,它确实有效。

答案 1 :(得分:0)

http://jsfiddle.net/techsin/snj4heoz/

在这里,您需要删除ui-radio-off课程,然后删除广告ui-radio-on课程。

var inputs = $('input[name=CustCat]');

inputs.filter('[value=' + type + ']').first().attr('checked', true).siblings('label').removeClass('ui-radio-off').addClass('ui-radio-on');