I have one label name as lblName and one checkbox name as chkId. if I click on lblName then i want the value of chkId should be checked . For that I am using the following code but its not working.
<!DOCTYPE html>
<html>
<head>
<script>
$(document).ready(function() {
$("[#name]").click(function() {
$('#' + $(this).attr("chkId")).prop('checked',
function(i, oldVal) { return !oldVal; });
});
});
</script>
</head>
<body>
<label id="lblName" runat= "server">Name</label>
<asp:CheckBox ID="="chkId" runat="server"/></body>
</html>
Any ideas?
You don’t need any javascript for this – put the checkbox inside the
labelelement. The browser will then put the check in the control when the label itself is clicked.Also, there appears to be a lot of syntax errors in your example – are these just typos?