开发者

Input box appears if dropdown "Other" is selected?

开发者 https://www.devze.com 2023-02-09 09:51 出处:网络
Here is my final code: <scri开发者_如何学Gopt type=\"text/javascript\"> jQuery(function() {

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消