JQuery實現父級選擇器(廣告實現)
阿新 • • 發佈:2018-06-08
ont highlight .com jquery實現 src absolute content 1.0 utf-8
效果圖如下:
HTML代碼如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> .left,.right{ position: fixed; top: 250px; } .left{ left: 0; } .right{ right: 0; } .left span,.right span{ width: 20px; height: 20px; background: #ccc; font-size: 14px; color: #333; position: absolute; right: 0; top: 0; text-align: center; cursor: pointer; } </style> <script src="js/jquery-1.12.4.min.js"></script> <script> $(function(){ $(‘span‘).click(function(){ $(this).parent().hide(500); }); }) </script> </head> <body> <div class="left"><img src="images/left.jpg" ><span>X</span></div> <div class="right"><img src="images/right.jpg" ><span>X</span></div> </body> </html>
JQuery實現父級選擇器(廣告實現)