相关疑难解决方法(0)

如何使用jQuery设置无线电选项onload

如何使用jQuery设置无线电选项onload?

需要检查是否未设置默认值,然后设置默认值

jquery radio-button

290
推荐指数
8
解决办法
59万
查看次数

选中父 div 时检查单选按钮?

我有一个单选按钮,如果用户单击其内部的 div,我希望可以选择该按钮。我有一个 div 的点击事件,但我似乎无法检查单选按钮。

继承人我的代码:

var new_div = document.createElement('div');
        new_div.setAttribute('id', 'controlDiv');
        new_div.setAttribute('class', 'ansClass');
var newAnswer = document.createElement('input');
        newAnswer.setAttribute('type', 'radio');
        newAnswer.setAttribute('name', 'choice');
        newAnswer.setAttribute('class', 'radioButton');
        $(newAnswer).attr("id", "button"+j);


        var newLabel = $("<label>", {id: "label"+j, class: "ansLabel", text: "answer"+j});


        $(new_div).append(newAnswer); 
        $(new_div).append(newLabel);



$( "#controlDiv" ).click(function() {
    var radButton = $(this).find('input[type=radio]');
    radButton.click();
      //  $(radButton).attr("checked", "checked");
});
Run Code Online (Sandbox Code Playgroud)

html jquery

0
推荐指数
1
解决办法
3573
查看次数

-2
推荐指数
3
解决办法
1万
查看次数

标签 统计

jquery ×3

html ×1

jquery-mobile ×1

radio-button ×1