Reputation: 315
Q1 A O B O C O D O
1 2
'-->When i select any radio button from Q1 then color of button '1' and button '2' must change shwon in image...
<!DOCTYPE html>
<html>
<head>
<style>
.ButtonClicked {
background-color:red;
}
</style>
<script src="jquery-2.1.3.js"></script>
<script>
$(document).ready(function () {
$(document).on('change', 'input[name="groupA"]:radio', function () {
// alert($(this).val());
$(#btn1).addClass('ButtonClicked');
});
});
</script>
</head>
<body>
Q1 <input type="radio" id="radio1a" name="groupA" value="1">
<input type="radio" id="radio2a" name="groupA" value="2">
<input type="radio" id="radio3a" name="groupA" value="3">
<input type="radio" id="radio4a" name="groupA" value="4">
<br>
<button id="btn1">1</button>
<button id="btn2">2</button>
</body>
</html>
when try above code button 1 color is not changed don't know whats the mistake i done..
EDIT: i forgot quotes in $(#btn1) anyway thanks..
Upvotes: 1
Views: 60
Reputation: 2210
you forgot the quotes try this
$("#btn1").addClass('ButtonClicked');
Upvotes: 1