After clicking on the element (drawing), I want to fadeOut.

Asked 2 years ago, Updated 2 years ago, 56 views

Development Environment:
Windows 10 64-bit browsers:GoogleChrome69.0.3497
Editor: Brackets (Release 1.13.0-17696)
Language Used: HTML/CSS/Javascript/jQuery

<Overview>
I'm studying for jQuery.
I specified fadeOut to make the movement "Clicking on a drawing on a web page (circle*1, square*2) causes the drawing to fade out," but clicking on the drawing does not fade out (nothing happens).Where should I fix it?

<!DOCTYPE html>
<html>
    <head>
        <style>
        #circle{
            width —150px;
            height —150px;
            border-radius: 50%;
            background-color:green;
            margin —10px;
        }
        .square{
            width —150px;
            height —150px;
            background-color:red;
            margin —10px;
        }
        </style>

    </head>
    <body>
        <!--
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
        </script>
        -->
        <script src="jquery-3.3.1.slim.min.js">/script>

        <divid="circle"></div>
        <div class="square"></div>
        <div class="square"></div>

        # I want to fade out when I click on the HTML element
        <script type="text/javascript">
            $("div").click(function(){
                $(this).fadeOut();
            })

        </script>     
    </body> 
</html>

javascript html jquery css

2022-09-30 17:04

1 Answers

I checked the error content (Uncaught TypeError: $(...).fadeOut is not a function) and found that someone asked a similar question in stackoverflow."According to that, ""The animation effect can't be used with ""slim"" jQuery, so you can introduce ""full"" jQuery,"" so I will consider it."I will settle it for now.Thank you for your comment.

https://stackoverflow.com/questions/934446/why-does-jquery-throw-the-error-fadeout-is-not-a-function


2022-09-30 17:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.