jQuery: hide and show an input element

后端 未结 6 2126
情话喂你
情话喂你 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 10:09

    Just add:

    $("#add_fields_placeholderValue").hide();
    

    After your change event declaration on page load.

    i.e.

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

    Working example: http://jsfiddle.net/bZXYR/

提交回复
热议问题