<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script src="jquery-3.3.1.js"></script>
<script>
$(function () {
$('#btn').click(function () {
var dvObj = $('<div style="width:300px;height:200px;background-color:yellow;position:absolute;right:0;bottom:0;">广告</div>').appendTo($('body'));
$('<span style="float:right;cursor:pointer">X</span>').click(function () {
$(this).parent().remove();
}).appendTo(dvObj);
});
})
</script>
</head>
<body>
<input type="button" name="name" value="显示广告" id="btn" />
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script src="jquery-3.3.1.js"></script>
<script>
$(function () {
$('#btn').click(function () {
var dvObj = $('<div style="width:300px;height:200px;background-color:yellow;position:absolute;right:0;bottom:0;">广告</div>').appendTo($('body'));
$('<span style="float:right;cursor:pointer">X</span>').click(function () {
$(this).parent().remove();
}).appendTo(dvObj);
});
})
</script>
</head>
<body>
<input type="button" name="name" value="显示广告" id="btn" />
</body>
</html>