js radio button click to select and cancel

The first is the html code, a radio button and a hidden field, which is convenient for passing data to the background.
<input type="checkbox" calss="span4"  name="randomPassword" id="randomPassword"  value="" onclick="changeBox(this)"/>
<input type="hidden" name="isRandomPassword" id="isRandomPassword" value=""/>
Next is the js code.
        /**
	*单选框点击事件
	*/
	function changeBox(obj) {
		var box= $(obj);
		if(obj.checked == true) {
			box.parent().parent().next().val("Y");
			box.parent("span").addClass("checked");
		} else {
			box.parent("span").removeClass("checked");
			box.parent().parent().next().val("N");		
                }
	}

$(function(){
		var randomPasswordBox= $("#randomPassword");
		var randomPasswordBoxClients = randomPasswordBox.val();
		if(randomPasswordBoxClients == 'Y') {
			randomPasswordBox.parent("span").addClass("checked");
			randomPasswordBox.attr("checked",true);
		}else {
			$("#randomPassword").val("N");
			$("#isRandomPassword").val("N");
		}
	})


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324818823&siteId=291194637