Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
- <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet">
- <script>
- document.addEventListener('DOMContentLoaded', function(event){
- clean(document.body);
- let _btns = document.getElementsByClassName('close');
- for(item of _btns){
- item.addEventListener('click', (e) => {
- // e.target.parentNode.remove();
- // e.target.closest('.media').remove();
- });
- }
- });
- const clean = (node) =>
- {
- for(var n = 0; n < node.childNodes.length; n ++)
- {
- var child = node.childNodes[n];
- if
- (
- child.nodeType === 8
- ||
- (child.nodeType === 3 && !/\S/.test(child.nodeValue))
- )
- {
- node.removeChild(child);
- n --;
- }
- else if(child.nodeType === 1)
- {
- clean(child);
- }
- }
- }
- </script>
- <style>
- .media{
- position:relative;
- }
- .media-object{
- border-radius:5px;
- }
- .close{
- position:absolute;
- top:0;
- right:5px;
- }
- </style>
- </head>
- <body>
- <div class="container" style="margin-top:50px">
- <div class="row">
- <div class="col-md-6 col-lg-6">
- <ul class="media-list main-list">
- <li class="media border-info card">
- <a class="pull-left" href="#">
- <img class="media-object" src="http://placehold.it/500x100" alt="...">
- </a>
- <div class="card-body">
- <h4 class="card-heading">Lorem ipsum dolor asit amet 1</h4>
- <p class="by-author">By John Doe</p>
- </div>
- <a href="#" class="close">x</a>
- </li>
- <li class="media border-info card">
- <a class="pull-left" href="#">
- <img class="media-object" src="http://placehold.it/500x100" alt="...">
- </a>
- <div class="card-body">
- <h4 class="card-heading">Lorem ipsum dolor asit amet 2</h4>
- <p class="by-author">By Jane Doe</p>
- </div>
- <a href="#" class="close">x</a>
- </li>
- <li class="media border-info card">
- <a class="pull-left" href="#">
- <img class="media-object" src="http://placehold.it/500x100" alt="...">
- </a>
- <div class="card-body">
- <h4 class="card-heading">Lorem ipsum dolor asit amet 3</h4>
- <p class="by-author">By Johnson Doe</p>
- </div>
- <a href="#" class="close">x</a>
- </li>
- </ul>
- </div>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement