I have a list of states in an option menu. I'd like to run a bit of jquery only when either CA or NV are selected. Here is what I have:
$('#state').change(function(){ var text=$('#state :selected').val();
$('.st').val(text);
});
Which I tried (unsuccessfully) to adapt to another bit of jquery like this:
<script type="text/javascript">
$(document).ready(function() {
$("#state").change(function() {
if ($("#state option[value='CA']").attr('selected')) {
$('#state').change(function(){ var text=$('#state :selected').val();
$('.st').val(text);
});
}
});
});
</script>
Any idea what needs to be changed for this to work?