I have been trying to connect the dots for days but due to lack of my knowledge in positioning and jQuery . I am making code a mess. I am trying to play video on click on there icons. I find these problem with my code
- The code works for the first time but after the video is closed. I cannot click to play again or another one.
- The play button isn't responsive, it overlap the text when in mobile view, whereas i want it to static but be responsive
- Due to the button position, in center from top and left, the left 50% has made horizontal scroll bar appear.
As i intend to use same jQuery code on other pages and same purpose, can i make it smarter and not write all code or copy paste again? Following is the code and here is the codepen
$(document).ready(function() {
$(".netball-intro").click(function() {
//jQuery(".sports-video").css("display", "block")
//jQuery("#bgvid").toggleClass("is-not-active");
$(".fullscreen").toggleClass("is-video-active");
$("#netball-intro").get(0).play();
$(".fullscreen").click(function(){
$(this).addClass('hidden');
});
});
$(".interview").click(function() {
//jQuery(".sports-video").css("display", "block")
//jQuery("#bgvid").toggleClass("is-not-active");
$(".fullscreen").toggleClass("is-video-active");
$(".interview").get(0).play();
$(".fullscreen").click(function(){
$(this).addClass('hidden');
});
});
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…