1

I am customizing checkout page. I try set value in form field by using Jquery but did not work.

for making test I will try to hide all input elements in checkout page such a simple task but did not work. alert have came but input element dose not hide.

I have get some idea to why its not working from this link. I have set jquery trigger before and after set value but nothing work.

require([ 'jquery', 'jquery/ui'], function($){

  $(document).ready(function(){

       $(window).load(function(){

       //$("input").trigger('keyup');
       $("input").hide();
       $("input").trigger('keyup');
       alert("hiwq");

    });
  });

});
2

It should be like below

require([ 'jquery', 'jquery/ui'], function($){

  $(document).ready(function(){
   // put your code here if you want it in document.ready     
  });

$(window).load(function(){

       //$("input").trigger('keyup');
       $("input").hide();
       $("input").trigger('keyup');
       alert("hiwq");

    });

});

check jquery-what-are-differences-between-document-ready-and-window-load

  • thanks @Minesh Patel, I have already tried but the problem still remain. now also alert get called but the input element did not get hide. – Bilal Usean Apr 19 '16 at 13:45
  • comment out this line // $("input").trigger('keyup'); and check – Minesh Patel Apr 19 '16 at 13:48
  • thank god its finally working after setting time delay. I think the input element not get load completely that is why its not found out input element. Thanks @Minesh Patel – Bilal Usean Apr 19 '16 at 13:53
  • always welcome @BilalUsean – Minesh Patel Apr 19 '16 at 13:55
1

after setting time delay my problem got solved.I think the input element not get load completely that is why its not found out input element to hide.

require([ 'jquery', 'jquery/ui'], function($){

  $(document).ready(function(){
  // put your code here if you want it in document.ready     
  });

 setTimeout(function(){

   $(window).load(function(){

   $("input").trigger('keyup');
   $("input").hide();
   //$("input").trigger('keyup');
   alert("hiwq");

   });

 }, 2000);

});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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