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.

asked Sep 20, 2018 at 5:41

1 Answer 1

0

Try below code for click event.

$(document).on("click", '#chk_shipusgovt', function(event) { 
 alert("Clicked!");
});
answered Sep 20, 2018 at 6:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.