jQuery: hide and show an input element

后端 未结 6 2125
情话喂你
情话喂你 2021-02-19 09:42

I\'m trying to do is hiding/showing a certain input object if a select value is checked.

Code in JSFiddle

The HTML part of the code is here:

<         


        
6条回答
  •  无人及你
    2021-02-19 09:52

    if you change the anonymous method into a callable function, you should be able to call it on Ready()

    e.g.

    $(document).ready(function () {
        $("#add_fields_placeholder").change(ShowIfOther);
        ShowIfOther();
    });
    
    function ShowIfOther() {
        if ($("#add_fields_placeholder").val() == "Other") {
            $("#add_fields_placeholderValue").show();
        } else {
            $("#add_fields_placeholderValue").hide();
        }
    }​
    

提交回复
热议问题