How to add background video stop button


Tags: jquery,html,css,html5

Problem :

I googled whole day but no result then I rerembered this website.

Can anyone tell me how to add stop button to background video?

html code:

<div id="background" class="background">
            <video id="video_background" src="video.mp4" autoplay>
        <div class="overlay"></div>
    </div><!--/ background-->

css code:

#video_background {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  width: 100%;
  height: 100%;
  z-index: -1000;
}

and website link: http://2gdmedia.com/dark



Solution :

With jQuery - button or element that will stop the video has the attribute class='stopElementClass'

$(function(){
    $('.stopElementClass').on('click', function(){
        $('#video_background').get(0).pause();
    }
});

Check out https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement


    CSS Howto..

    How to set an image when we select its sub menu

    How to display CSS files in Django blog?

    How do I center text in a span?

    How to distribute floated elements evenly with a dynamic column and row count in CSS?

    How to position text over an image in css

    How to change css style by using Unicode Hexadecimal

    How to let the browser cache css and js files for a https site?

    How to load specific set css commands only at the first browsing of the web site?

    How do I break the border around text in css?

    JavaScript: How to clear my custom keyboard mappings and use the default ones

    How to apply style to the divs that are added dynamically?

    How to make a website to occupy the entire element?

    Increasing font size for links on hover changes background color size, how to stop this?

    CSS / jQuery: How to prevent tooltip from disappearing behind border of main wrapper (working code)

    How to remove
     tag

    How to trigger css3 rotate effect by clicking?

    How to center a div and keep the alignment to its nested floating divs?

    HTML CSS How to stop a table cell from expanding

    How to make a css media query snippet in ATOM editor

    how to redirect page

    How to use CSS transition effects

    How can the css dottled border be implemented?

    how to revert to original css values after .css() method

    How to transform simple CSS box

    How can I center align the list horizontally?

    How to change html (jade template) to use *.min js and css in production?

    Button on ng-mouseover & ng-mouseleave won't get shown as expected - AngularJS

    How to add CSS to page to the bottom of the custom chrome extension

    How do I create html/css elements in a shape of a circle?

    How to dim an image keeping transparency untouched with CSS or JS?