效果图如下:
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实现父级选择器(广告实现)
原文地址:https://www.cnblogs.com/wf-skylark/p/9157442.html