On the website I have a button with an addClass statement. Before this button is clicked there is a possible option to check a radio button. Is it possible to not add the class if the button is checked?
The current code:
Radio button:
<input type="radio" name="test_name" id="test_id" value="0" title="test_title"
onclick="$test_click" class="radio" /><label>radio text</label>
Button:
<button type="button" title="button_test" class="button" onclick="addClass();">
button text</button>
addClass statement (working):
<script type="text/javascript">
function addClass() {
$j('.test').addClass('test2'); }
</script>
Help would be highly appreciated.
You can use is() with the :checked selector and do something like:
function addClass()
{
if (!$j("#test_id").is(":checked")) {
$j(".test").addClass("test2");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With