show text in select box in jquery
I have a select box and according the selected value I want to show the
value in next selected box. My code is like:
$('#category').change(function(){
var cat_val = $('#category option:selected').text();
if(cat_val == 'Online'){
$('#workshop-row').hide();
$('#bu_id').val(22);
}else{
$('#workshop-row').show();
}
});
By doing $('#bu_id').val(22); I can get the value. But I need to set the
text not val() like
$('#bu_id option:selected').text("Online");
That means if I select Online from the first select box then in the 2nd
select box, the value whose text is Online will be selected.
Please guide me. Thanks in advance.
No comments:
Post a Comment