If I do a click based on id a border and background color is added. If I do another click based on id of button it should change the border and background color to another color but the click for button is not working to change color from green to black. I can't figure why. My code snippet is below. The if statement is never evaluated.
Thank You In Advance
if ($(".g_card").on('click', function() {
$('#addon_1').addClass('baddon_1add');
$("#gift_occasion").toggle();
}));
if ($("#work").on('click', function() {
alert("button not working");
$('#addon_1').removeClass('baddon_1add').addClass('.baddon_1');
}));
.baddon_1 {
border: solid 1px #808080;
background-color: #FFFFFF;
}
.baddon_1add {
border: solid 2px #2D6E20;
background-color: #EFF7ED;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div class="g_card">
<input type='button' id="work" value='-' class='qtyminus' field='quantity' />
<input type='text' id="g_quantity" name='quantity' value='0' class='qty' />
<input type='button' id="some_occasion" value='+' class='qtyplus' field='quantity' />
<br />
<div id="gift_occasion" style="display:none">
<select>
<option>Occasion</option>
</select>
</div>
</div>
IFitself in this context is pointless..clickevent binding wrong. You do not need theifstatement if you are trying to bind a click event. Other than that, why do you bind your first click event for the whole container?