jQuery 隐藏网页中第5个div
$("div").eq(4).hide();//eq()写需要隐藏的索引
完整代码如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>测试</title> <script src="../js/jquery-3.3.1.js"></script> <style type="text/css"> </style> <script type="text/javascript"> $(document).ready(function(){ $("div").eq(4).hide();//eq()写需要隐藏的索引 }) </script> </head> <body> <div>1</div> <div>2</div> <div>3</div> <div>4</div> <div>5</div> </div> </body> </html>