So have a script named script.js:
var newLabel = '';
$('#payment_amount').on('change', function(){
$('#change_label').text(newLabel); //Change the text before changing the value
switch(this.value){
case 'junior':
newLabel = 'Junior Account';
break;
case 'premium':
newLabel = 'Premium Account';
break;
}
}).trigger('change');
I'm calling it to my html file by:
<script type="text/javascript" src="script.js"></script>
My code for select is this:
<select id = "payment_amount">
<option class="junior" value="junior">Junior</option>
<option class="premium" value="premium">Premium</option>
</select>
<label id="change_label">Hello</label>
I already tried directly putting my js code to the html by adding it to the tag but I'm still not having any luck. Where did I go wrong with this one?