0

I have created a custom shipping method + shipping form like below.

enter image description here

I want to add click event for the check box.

I tried this code in my phtml file.

<script>
require(
    [
        'jquery',
        'Magento_Ui/js/modal/modal'
    ],
    function(
        $,
        modal
    ) {

        $("#chk_shipusgovt").click(function(){
            if($(this).prop("checked") == true){
                alert("Checked");
                document.getElementById("txt_shipusgovt").style.display = "block";
            }

            else if($(this).prop("checked") == false){
                alert("Not Checked");
                document.getElementById("txt_shipusgovt").style.display = "none";
            }
        });   
    }
);

This is not working, how can i add this JQuery function to be work.Great help if any one can help me to short it out this issue.

1 Answer 1

0

Try below code for click event.

$(document).on("click", '#chk_shipusgovt', function(event) { 
    alert("Clicked!");
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.