如果选择“是”,我有以下 jQuery 代码显示输入框。我的问题是,当我遇到错误时,下拉框的状态会被记住是/否,但如果选择是,它不会显示输入框,为什么?
jQuery:
$("#add_fields_placeholder").change(function()
{
if($(this).val() == "yes")
{
$('label[for="add_fields_placeholderValue"]').show();
$("#add_fields_placeholderValue").show();
}
else
{
$('label[for="add_fields_placeholderValue"]').hide();
$("#add_fields_placeholderValue").hide();
}
});
看法:
<label for="add_fields_placeholder">Placeholder: </label>
<select name="add_fields_placeholder" id="add_fields_placeholder">
<option value="">Please Select</option>
<option value="yes" <?php echo set_select('add_fields_placeholder','yes', ( !empty($placeholderType) && $placeholderType == "yes" ? TRUE : FALSE ));?>>Yes</option>
<option value="no" <?php echo set_select('add_fields_placeholder','no', ( !empty($placeholderType) && $placeholderType == "no" ? TRUE : FALSE ));?>>No</option>
</select>
<label for="add_fields_placeholderValue">Placeholder Text: </label>
<input type="text" name="add_fields_placeholderValue" id="add_fields_placeholderValue" value="<?php echo set_value('add_fields_placeholderValue'); ?>">