在浏览器重新加载时设置onchange事件 [英] Setting an onchange event when the browser reloads

查看:230
本文介绍了在浏览器重新加载时设置onchange事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码在选择yes时显示输入框的方面工作正常。我的问题是,如果在提交期间任何其他框出错,并且占位符下拉列表设置为yes,则不会显示placeholderValue输入框。

I have the following code that works fine in the respect that it shows the input box when yes is selected. My issue is if there is an error with any of the other boxes during the submit and the placeholder dropdown is set to yes it does not show the placeholderValue input box.

如何我可以调整这段代码,所以如果我的代码出错,如果输入框设置为yes,它将显示placeholderValue输入框。

How could I adjust this code so if my code does error and if the input box is set to yes it will display the placeholderValue input box.

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();
        }
            });


推荐答案

您需要触发< select> : $(#add_fields_placeholder)。触发器(更改);

这篇关于在浏览器重新加载时设置onchange事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆