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 change button CSS attributes

    How to inherit CSS using Less?

    How to position background image horizontally left and vertically center?

    How to add javascript to an image from the content_wrapper in the css stylesheet

    How to change the CSS of page dynamically based on value?

    How do I change the color of Semantic UI icons?

    How can I use a `comment` fa-icon and a text div to display the number of messages a user has?

    How do I script such that my panoramic image can be panned left and right up to its edges?

    How to apply CSS string using Javascript/jQuery without parsing/tokenizing to retrieve property-value pairs?

    How to use CSS to surround a number with a circle?

    How to make possible vertical scroll on popup and disable vertical scroll for page by using CSS?

    How to place something in a triangle-shaped box?

    How do I stop my :after content from blocking my anchor?

    CSS: how do I position my slideshow counter up into the slideshow

    how to vertical align a table inside a div

    CSS: How to clear a floating object only one level, not the all the way to the left?

    How to identify device to make separate css for iPad and Galaxy Tab?

    How to remove CSS spaghetti in legacy web app?

    How to apply CSS properties of one class in another

    how to overwrite css style in asp.net page?

    How to target html area maps with css

    div shown with jquery is cropped

    How to target specific img using css

    How to place two divs next to each other?

    How to customized select element through css?

    How to get css div to stretch to 100% of window

    How to know values of all attributes and properties of a tag element in HTML

    How to style pseudo counter in CSS

    How can I increase input text elements' width via CSS?

    JSSOR slider: Image Gallery demo keeps showing highlight image on mobile