我的代码在 codepen(下面的链接)中完美运行,但由于某种原因在浏览器中它不起作用。我正在从 localhost 运行代码,但按钮没有响应。
代码
这是我的 VS 代码
jQuery(function($) {
$('.removeDiv').on('click', function() {
$(this).closest('#cookieNotice').remove();
});
});
<html>
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<!-- Font Awesome CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.2/css/all.min.css">
<!-- Index Javascript-->
<script type="text/javascript" src="index.js"></script>
<title>Urabiliti Home Page</title>
</head>
<body>
<!-- Footer -->
<footer class="page-footer font-small blue fixed-bottom bg-light" id="cookieNotice">
<!-- Copyright -->
<div class="footer-copyright text-center py-3">This website uses
<a href="https://mdbootstrap.com/education/bootstrap/"> cookies</a> to ensure you get the best experience on our website
</div>
<!-- remove cookie notice -->
<div class="removeDiv text-center">
<button type="button" class="btn btn-primary mb-4">Got it</button>
</div>
展开片段我希望 div 被删除 onclick
青春有我
相关分类