How do I add and remove a class only to selected radio button of a set of radio buttons?
<table class="radioClass" role="set1"><tbody><tr><td><input type="radio" value=" Yes " id="" name="j_id0:j_id37:j_id41"> label for="j_id0:j_id37:j_id41:0"> Yes </label></td><td><input type="radio" value=" No " id="" name="j_id0:j_id37:j_id41"<label for="j_id0:j_id37:j_id41:1"> No </label></td></tr></tbody></table>
$(document).ready(function(){
$("input[type='radio']").click(function(){
var radioValue = $("input:checked").val();
if(radioValue){
//alert("Your are a - " + radioValue);
$("input:checked").toggleClass("checked");
}
});
First remove checked
class from all radio buttons and then add to specific selected one. This is how you can do this:
if(radioValue){
$("input[type='radio']").removeClass("checked");
$(this).toggleClass("checked");
}
I am building an offline functionality for a Cordova app that I am developing and I have a php file that gets only the list of images and I have taken the JSON from it and saved in the client device ...
I am building an offline functionality for a Cordova app that I am developing and I have a php file that gets only the list of images and I have taken the JSON from it and saved in the client device ...
I'm working on a project, and we use a lot of coding languages for different parts. I've tried to simplify the problem as much as I can, and came up with the following JSfiddle. The problem is, I ...
I'm working on a project, and we use a lot of coding languages for different parts. I've tried to simplify the problem as much as I can, and came up with the following JSfiddle. The problem is, I ...
I'm working on my first GatsbyJS project (and hosted on Netlify) and over the past few weeks have noticed that everything is very speedy during development, but when built and hosted the pages are ...
I'm working on my first GatsbyJS project (and hosted on Netlify) and over the past few weeks have noticed that everything is very speedy during development, but when built and hosted the pages are ...
here i didn't understand what happen when i use var before variable in function it give me different out put and with out using var also i got a different output here is a code that you can easily ...
here i didn't understand what happen when i use var before variable in function it give me different out put and with out using var also i got a different output here is a code that you can easily ...