Toggle between fading in and out the <div> element, when clicking the button. - Javascript jQuery

Javascript examples for jQuery:Fade

Description

Toggle between fading in and out the <div> element, when clicking the button.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("div").fadeToggle(1000);
    });/*  w  ww. java 2s. c o  m*/
});
</script>
</head>
<body>

<button>Click to fade in/out div</button><br><br>

<div style="width:80px;height:80px;background-color:red;"></div>

</body>
</html>

Related Tutorials