I'm trying to create a program that allows the user to choose an action to apply to an image. I'm using a radio button list to assign the action. I'm having a difficult time trying to get my JQuery code to apply the selected effect to the image. It either doesn't pass the value of the radio button, or it does pass it, but never changes after the first selection. Any advice is greatly appreciated.
$(function(){
//when the "apply" button is clicked, it will apply the selected effect, from the menu, to the image.
$('#applyBtn').on('click', function () {
if(checkedEffect.value == 'Hide' && checkedEffect.checked)
$('img').hide();
else if(checkedEffect.value == 'Show' && checkedEffect.checked)
$('img').show('fast');
else if(checkedEffect.value == 'Toggle' && checkedEffect.checked)
$('img').toggle();
else if(checkedEffect.value == 'Fade_out' && checkedEffect.checked)
$('img').fadeOut();
else if(checkedEffect.value == 'Fade_in' && checkedEffect.checked)
$('img').fadeIn();
else if(checkedEffect.value == 'Slide_up' && checkedEffect.checked)
$('img').slideUp();
else if(checkedEffect.value == 'Slide_down' && checkedEffect.checked)
$('img').slideDown();
else if(checkedEffect.value == 'Slide_toggle' && checkedEffect.checked)
$('img').slideToggle();
else if(checkedEffect.value == 'Fade_to' && checkedEffect.checked)
$('img').fadeTo();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form class = "effectsForm">
<input type = "radio" name = "manip" id = "manip" value = "Hide"> Hide<br/>
<input type = "radio" name = "manip" id = "manip" value = "Show"> Show<br/>
<input type = "radio" name = "manip" id = "manip" value = "Toggle"> Toggle<br/>
<input type = "radio" name = "manip" id = "manip" value = "Fade_out"> Fade out<br/>
<input type = "radio" name = "manip" id = "manip" value = "Fade_in"> Fade in<br/>
<input type = "radio" name = "manip" id = "manip" value = "Slide_up"> Slide up<br/>
<input type = "radio" name = "manip" id = "manip" value = "Slide_down"> Slide down<br/>
<input type = "radio" name = "manip" id = "manip" value = "Slide_toggle"> Slide toggle<br/>
<input type = "radio" name = "manip" id = "manip" value = "Fade_to"> Fade to<br/>
<button type = "button" id = "applyBtn">Apply</button>
</form>
<div class = "imageContainer">
<img alt="testing" src="images\testing.jpg"/>
</div>