选择选项时jQuery显示文本框

我有以下代码:

 Type 1 Type 2 Type 3 Other   

我想要做的是使用jQuery默认隐藏下面的文本框,然后在用户从下拉列表中选择其他选项时显示它。

这里不需要任何CSS。

 $('#sel').change(function() { var selected = $(this).val(); if(selected == 'Other'){ $('#other').show(); } else{ $('#other').hide(); } }); 
   $('#sel').change(function() { $('#other').css('display', ($(this).val() == 'Other') ? 'block' : 'none'); }); 

试试这个:

   

JQuery的:

 $(function(){ // hide by default $('other').css('display', 'none'); $('selectbox_id').change(function(){ if ($(this).val() === 'Other') { $('other').css('display', 'block'); } }); });