I'm experiencing difficulties with a jQuery script that should display the content of a div based on selected options in a drop-down menu.
The drop-down menu is supposed to provide numerical values for a calculator to determine a loan amount. However, when I input numerical values for both option value and corresponding div id, the code fails to work. Surprisingly, if I change these values to words, it works perfectly fine.
Is there a workaround to make this function using numerical values?
<select name="apr" id="apr" class="loan-calculator__input" >
<option value="">Select</option>
<option value="4.7" class="good">Good</option>
<option value="14.9" class="fair">Fair</option>
<option value="29.9" class="poor">Poor</option>
</select>
</div>
<div id="4.7" style="display:none;" class="rating" ><p>Good - </p>
</div>
<div id="14.9" style="display:none;"class="rating" ><p>Fair</p>
</div>
<div id="29.9" style="display:none;" class="rating"><p>Poor </p>
</div>
(function($) {
$(document).ready(function() {
$('#apr').change(function(){
$('.rating').hide();
$('#' + $(this).val()).show();
});
});
})(jQuery);
A jsfiddle has been set up to demonstrate the issue - http://jsfiddle.net/nineseven/W37np/