I have a radio button that I would be like to be selectable if the user clicks the div thats its inside of. I have a click event for the div but I can't seem to get the radio button to check.
heres my code:
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");
});