<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Terms of Service</title>
<link rel="stylesheet" href="./scroll-to-accept.css" />
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
<script>
function unhideTOS() {
document.getElementById("text").style.display = "";
}
</script>
<script>
function unlockBTN() {
document.getElementById("text").style.display = "";
}
</script>
<div class="tacbox">
<!-- The code for the checkbox + download if checked. -->
I agree to these ‌<a href="#tos" class="yes">Terms and Conditions.</a>
<br>
<a id="text" style="display:none" href="file.doc" Download>Download!</a>
</div>
<div class="TOSHIDE fade-in-image">
<div class="wrapper-all">
<div class="wrapper">
<div class="terms-and-conditions">
<h1>Terms and Conditions</h1>
<p>Disclaimer THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
PURPOSE. You are the Current Maintainer of the Software, and to permit recipients of the Licensed Product for
any such warranty, support, indemnity or liability obligations to one or more recipients of Covered Code.
However, You may do so in a commercial product offering.</p>
<hr>
</div>
<button class="accept" disabled autocomplete="off" id="myCheck" onclick="unlockBTN()">Accept</button>
</div>
</div>
</div>
<script src="./scroll-to-accept.js"></script>
</body>
</html>
function scrollToAccept() {
const terms = document.querySelector('.terms-and-conditions');
const button = document.querySelector('.accept');
// const watch = document.querySelector('.watch');
if (!terms) {
return; // quit function because there is no terms
}
// fires on page load because can't find element
function obCallback(payload) {
// console.log(payload[0].isIntersecting); // whether element is in view or not
// console.log(payload[0].intersectionRatio); // how much of the element is showing
if (payload[0].intersectionRatio === 1) {
button.disabled = false;
// stop observing the last element
ob.unobserve(terms.lastElementChild);
}
}
// takes in callback parameter
// will be called every time it needs to check if something is currently on the page
// watcher (needs to be told what to watch
const ob = new IntersectionObserver(obCallback, {
root: terms,
threshold: 1,
});
// call observe method on what we want to watch
// ob.observe(watch);
ob.observe(terms.lastElementChild);
}
scrollToAccept();
$('.yes').on('click', function(e) {
e.preventDefault();
$('.TOSHIDE').toggleClass('active');
//$(this).parents('ul').next().toggleClass('active');
})
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.