0

How to add loader for image on page load .. I want to add loader until the main image is ready on page load.

how to do this

Thanks

Update:

<div class="outer-box">
    <nav class="social">
        <div class="box">
            <p>Showing a display Loading Icon Until the Page Loads Completely..</p>
            <img id="new" class="main-img" src="http://magento/pub/media/images/sizechart/babydoll.png"/></div>

    </nav>
</div>
<script>
    require([
        'jquery'
    ], function ($) {
        $(document).ready(function(){alert("sdfsdf");

            // show loading image
             $('body').trigger('processStart');

            // main image loaded
            $('.main-img').on('load', function(){
                // hide the loading image
                $('body').trigger('processStop');
            });
        });
</script>
0

Try the below jquery code :

// show loading image
$('.loader_image_class').show();

// main image loaded
$('.main_image_class').on('load', function(){
  // hide the loading image
  $('.loader_image_class').hide();
});
  • its not working – Mano M Feb 21 at 6:42
  • Getting any error in console? – Amit Naraniwal Feb 21 at 6:43
  • No ... ........ – Mano M Feb 21 at 6:44
  • Can you share your code and where you adding this code? – Amit Naraniwal Feb 21 at 6:45

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.