Here is my final code:
<scri开发者_如何学Gopt type="text/javascript">
jQuery(function() {
jQuery("#company").change(function() {
var val = jQuery(this).val();
if(val == 'other') {
jQuery('input[name="other"]').fadeIn('slow');
} else {
jQuery('input[name="other"]').fadeOut('slow')();
}
});
});
</script>
$(function() {
$("#dropdown").change(function() {
var val = $(this).val();
if(val == 'other') {
$('input[name="other"]').show();
} else {
$('input[name="other"]').hide();
}
}).change();
});
Updated. as box9 suggested, since you want the function to trigger on page load.
精彩评论