how to start click or change function from inside js
<p>The problem is,  <code>$('#menu').val(menu).trigger('change');</code> and <code>$('.parentcheck').val(0).attr('checked', true).trigger('click');</code> changes their state but doesn't fire their functions <code>$("#menu").change(function () {</code> and <code>$(".parentcheck").click(function () {</code>. How to deal with that problem?</p>

<p>My js code looks like that</p>

<pre><code>$(document).ready(function () {

    $("#parent").hide();
    $(".parentcheck").click(function () {
        if ($(this).val() === "0") {
            $("#parent").hide().find('option:selected').removeAttr('selected');

        }
        if ($(this).val() === "1") {
            if ($("#parent option").length &gt; 0) {
                $("#parent").show();
            }

        }
        $("#menu").change();
    });

    $("#menu").change(function () {
        var selectedmenu = $("#menu").val();
        var parentcheck = $(".parentcheck:checked").val();
        if (selectedmenu != '' &amp;&amp; selectedmenu != '0') {
            $.ajax({
                type: "POST",
                url: "processor/optionsgenerator.php",
                data: {
                    menu: selectedmenu
                },
                success: function (result, status, xResponse) {
                    if (result != '') {
                        if (parentcheck == '0' || !$(".parentcheck").is(":checked")) {
                            $("#parent").hide();
                        } else {
                            $("#parent").html(result);
                            $("#parent").show();
                        }
                    } else {
                        alert('Baza ilə əlaqədə problem var.');
                        $("#parent").hide();
                    }
                },
                error: function (e) {
                    alert(e);
                }
            });
        } else $("#parent").hide();
    });
$('#menu').val(menu).trigger('change'); 
if(parent==0) {
$('.parentcheck').val(0).attr('checked',true).trigger('click');
}
else {
$('.parentcheck').val(1).attr('checked',true).trigger('click');
$('#parent').val(parent);   
}   
    }); 
</code></pre>
