Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<script>
  $(document).ready(function() {
    function highlightElement(element) {
            const background = $('<div></div>');
          
            $(background).css({
                    'position':'relative',
                    'top':'-' + $(element).height() + 'px',
                    'background-color':'yellow',
                    'z-index':'-10',
                    'height':$(element).height() + 'px',
                    'width':$(element).width() + 'px',
                    'margin-bottom':'-' + $(element).height() + 'px',
                    'padding':'0px',
                    'float':'left',
            });
            $(background).appendTo(element);
            $(background).fadeOut(5000);
            return true;
    }
    $('#click-to-highlight').click(function() {
        highlightElement($('#paragraph-to-highlight'));
    });
  });
</script>
  
  <button id="click-to-highlight">Highlight Text</button>
<p id="paragraph-to-highlight">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam non nibh tincidunt, interdum arcu eget, consectetur nisl. Sed auctor ornare lectus et commodo. Nulla nec commodo neque. Nullam pellentesque arcu quis sagittis aliquet. Aliquam ligula lectus, pharetra eu cursus at, tempus et magna. Ut elit turpis, congue sit amet fringilla eget, blandit vel enim. Pellentesque tincidunt nisl eu quam pellentesque, nec mollis mauris eleifend. Praesent faucibus ipsum velit, at luctus mi consectetur et. Vivamus accumsan scelerisque felis, sit amet ornare nisi.</p>
<p>Non-highlighted text.</p>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
HoldOffHungerpro
0viewers