<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JQ</title> <style> div { width: 100px; height: 100px; background: yellow; border: 1px red solid; } </style> </head> <body> <div></div> <div></div> <div></div> <input type="button" value="yes,im ok"> <!-- JS --> <script src="js/jquery-3.2.1.min.js?1.1.11"></script> <script> $('input').click(function(){ $('div:eq(0)').toggle(3000) $('div:eq(1)').slideToggle(3000) $('div:eq(2)').fadeToggle(3000) }) </script> </body> </html>
Summary:
toggle on the entire element Visible style attributes perform animation transition processing
SlideToggle only performs transparency transition processing on elements
fadeToggle only performs transparency transition processing on elements
The above is the detailed content of The difference between toggle / slideToggle / fadeToggle. For more information, please follow other related articles on the PHP Chinese website!