Using fadein and fadeout for Bootstrap Modal in jQuery

Last Reply 15 days ago By dharmendr

Posted 15 days ago


I use fade in and fadeoutand now I want to use Fade in for modal('show') and FadeOut for .modal('hide')

    <script type="text/javascript">
        $(document).ready(function () {
            //Check to see if the window is top if not then display button
            $(window).scroll(function () {
                if ($(this).scrollTop() > 100) {
                } else {
            //Click event to scroll to top
            $('.scrollToTop').click(function () {
                $('html, body').animate({ scrollTop: 0 }, 800);
                return false;

how I can use it?

Best regards


You are viewing reply posted by: dharmendr 15 days ago.
Posted 15 days ago

Hi nedash,

Check this example. Now please take its reference and correct your code.


    <meta charset="utf-8" />
    <div class="d-sm-inline-flex">
        <div class="row">
            <div class="modal fade" id="myModal1" tabindex="-1" role="dialog">
                <div class="modal-dialog">
                    <img id="Image1" class="behtopM" src="" />
    <script src=""
            integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src=""
            integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <link rel="stylesheet" href=""
          integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <script src=""
            integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
    <script type="text/javascript">
        $(function () {
            setTimeout(function () {
            }, 2000);
    <style type="text/css">
        .behtopM {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);

        #imagebeh {
            width: 100px;
            height: 100px;
            border: 1px solid red;

        .fade {
            transform: scale(0.3);
            opacity: 0;
            -webkit-transition: all .2s linear;
            -o-transition: all .2s linear;
            transition: all .2s linear;

                opacity: 0.4;
                transform: scale(1);