简体   繁体   中英

Load jquery function and progress bar on button click

I've a page on which i've a button, on clicking that i want to load a jquery function which loads a progress bar.. On reaching 100% the progress must be hidden and the page must be redirected to another URl..

But when i click the button the progress is not loading at all..

The original demo of the progress bar can be found below.. http://www.jqueryscript.net/demo/Graphical-Circular-Timer-with-jQuery-CSS3-pietimer/

This is what i've done so far..

 <script type="text/javascript">
   $(document).ready(function () {
       $('#btn').click(function () {
           $(function () {
               var timer = $('#timer');
               var url = "http://jquery4u.com";
               timer.pietimer({
                   timerSeconds: 1,
                   color: '#234',
                   fill: false,
                   showPercentage: true,
                   callback: function () {
                       timer.hide();
                       $(location).attr('href', url);
                   }
               });
           });
       });
   });
  </script>
  </head>
  <body>
  <div id="parent">
  <div id="timer"></div>
  </div>
  <div>
    <input id="btn" type="button" value="button" />
  </div>

Plz help..

You don't want to wrap the location object in jQuery.

Change:

$(location).attr('href', url);

To:

window.location = url;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM